The filter_var_array() function in PHP allows you to filter ______ inputs at once.

  • single
  • multiple
  • individual
  • specific
The filter_var_array() function in PHP allows you to filter multiple inputs at once. It takes an input array and applies a specified filter to each element of the array. For further information, visit: http://php.net/manual/en/function.filter-var-array.php

What are some steps you might take when creating a MySQL table using PHP?

  • Connect to the MySQL server, select the database, execute a CREATE TABLE query, handle errors, close the connection
  • Connect to the MySQL server, execute a SELECT query, handle errors, close the connection
  • Connect to the MySQL server, execute an INSERT INTO query, handle errors, close the connection
  • Connect to the MySQL server, execute a DELETE query, handle errors, close the connection
When creating a MySQL table using PHP, you would typically follow these steps: 1. Connect to the MySQL server using the appropriate credentials. 2. Select the database where you want to create the table. 3. Execute a CREATE TABLE query using the mysqli_query function. 4. Check the return value of the mysqli_query function to handle any errors that may have occurred during the query execution. 5. Close the connection to the MySQL server using the mysqli_close function. These steps ensure that you establish a connection, create the table, handle any errors, and properly close the connection when you're done.

You are writing a PHP script and you need to collect data sent in the URL's query string. How would you do this using the $_GET superglobal?

  • Access the data using the $_GET['key'] syntax.
  • Access the data using the $_GET->$key syntax.
  • Access the data using the $_GET['key'] method.
  • Access the data using the $_GET->key method.
To collect data sent in the URL's query string in PHP using the $_GET superglobal, you can access the data using the $_GET['key'] syntax, where 'key' represents the name of the parameter in the query string. For example, if the URL is "example.com/page.php?id=123", you can access the value "123" by using $_GET['id']. This allows you to retrieve and process the data passed through the URL using the GET method. Learn more: https://www.php.net/manual/en/reserved.variables.get.php

The === operator in PHP checks if the values of two operands are ______ and of the ______ type.

  • Equal and same
  • Equal and different
  • Not equal
  • Not equal and same
The === operator in PHP checks if the values of two operands are equal and of the same type. It performs a strict comparison, meaning that it not only checks for equality but also ensures that the data types of the values are the same. For example, $num1 === $num2 will return true if $num1 is equal to $num2 and both have the same data type, and false otherwise. Learn more: https://www.php.net/manual/en/language.operators.comparison.php

The ______ keyword is used in PHP to make a local variable accessible globally.

  • local
  • global
  • this
  • super
The global keyword in PHP is used to make a local variable accessible globally. By using the global keyword followed by the variable name within a function, you can access and modify the value of the variable globally, outside the function's local scope. This allows you to work with local variables in a wider scope. However, it is generally recommended to minimize the use of global variables for better code organization and maintainability. Learn more: https://www.php.net/manual/en/language.variables.scope.php#language.variables.scope.global

You can create an object in PHP by using the new keyword followed by the class name like $object = new ______.

  • ClassName
  • ObjectName
  • NewObject
  • CreateObject
In PHP, you can create an object by using the new keyword followed by the class name and parentheses. The correct option is "ClassName." This syntax instantiates an object of the specified class. For more information, consult the PHP documentation on creating objects: http://php.net/manual/en/language.oop5.php

You have a variable in your PHP script that needs to hold a simple true or false value. What data type would you use?

  • int
  • float
  • string
  • boolean
To hold a simple true or false value in PHP, you would use the boolean data type. The boolean data type is specifically designed to store either true or false values. It is commonly used in conditions, logical operations, or to indicate the success or failure of an operation. By using the boolean data type, you can ensure that the variable only holds the expected true or false values, providing clarity and correctness to your code. Learn more: https://www.php.net/manual/en/language.types.boolean.php

Once a constant is set in PHP, it cannot be ______ or ______.

  • Modified or redefined
  • Accessed or printed
  • Declared or assigned
  • Deleted or removed
Once a constant is set in PHP, it cannot be modified or redefined during the script execution. Constants are intended to store fixed values that remain constant throughout the execution of the script. Once defined, their value cannot be changed. Any attempt to modify or redefine a constant will result in an error. This behavior ensures that constants maintain their fixed value and avoid accidental changes. Learn more: https://www.php.net/manual/en/language.constants.php

You need to create a file in your PHP script, write to it, and ensure that the file is closed properly after writing. How would you do this?

  • Use the fopen() function with 'w' mode to create the file and obtain a file handle, then use the fwrite() function to write content to the file. Finally, use the fclose() function to close the file.
  • Use the file_put_contents() function to create the file and write content to it. The function handles file creation and writing, so no explicit file handle or closing is required.
  • Use the touch() function to create the file, then use the fwrite() function to write content to the file. Finally, use the fclose() function to close the file.
  • Use the mkdir() function to create a directory instead of a file.
To create a file, write to it, and ensure proper closing in PHP, you would use the fopen() function with 'w' mode to create the file and obtain a file handle. Then, you can use the fwrite() function with the file handle to write content to the file. Finally, you would use the fclose() function to close the file and release the associated resources. This ensures that the file is created, written to, and closed properly.

You need to retrieve the error message after an email sending operation fails in your PHP script. How would you do this using mail functions?

  • Use the error_get_last() function to retrieve the last PHP error message
  • Use the error_reporting() function to set error reporting level
  • Use the mysqli_error() function to retrieve the error message
  • Use the pdo_error() function to retrieve the error message
If there is an error during the execution of a mail function in PHP, you can use the error_get_last() function to retrieve the last PHP error message. This function returns an array containing information about the last error that occurred. You can then access the error message using the 'message' key of the returned array. For example, $error = error_get_last(); $errorMessage = $error['message']; retrieves the error message. This allows you to retrieve and handle the error message after an email sending operation fails in your PHP script.