In PHP, variables declared inside a function can be accessed outside of that function.

  • TRUE
  • FALSE
Variables declared inside a function in PHP have a local scope. This means they are only accessible within that specific function. Once the function execution ends, the local variables are destroyed and cannot be accessed from outside the function. In order to access variables across different scopes, you would need to use return statements or pass them as parameters. Learn more: https://www.php.net/manual/en/language.variables.scope.php

Which of the following are common uses of the filter_input_array() and filter_var_array() functions in PHP?

  • Sanitizing user input
  • Validating form submissions
  • Filtering data from external sources
  • All of the above
Both the filter_input_array() and filter_var_array() functions in PHP are commonly used for sanitizing user input, validating form submissions, and filtering data from external sources. These functions provide a convenient way to apply filters to multiple inputs at once. Learn more at: http://php.net/manual/en/function.filter-input-array.php and http://php.net/manual/en/function.filter-var-array.php

How are the keys assigned in an associative array in PHP?

  • Keys are provided explicitly by the programmer.
  • Keys are assigned randomly based on the element's value.
  • Keys are assigned automatically by PHP based on the element's position.
  • Keys are assigned alphabetically based on the element's value.
In an associative array in PHP, the keys are provided explicitly by the programmer. When declaring an associative array, you define the keys and their corresponding values. Each key-value pair is defined within the array, allowing you to associate specific values with specific keys. The keys can be strings or integers, and they provide a convenient way to retrieve the corresponding values using the associated keys. Learn more: https://www.php.net/manual/en/language.types.array.php#language.types.array.syntax

In PHP, the while loop tests the condition ______ executing the block of code.

  • before
  • after
  • during
  • alongside
In PHP, the while loop tests the condition before executing the block of code. The condition is evaluated at the beginning of each iteration. If the condition evaluates to true, the block of code is executed. If the condition evaluates to false, the loop is terminated, and the execution continues with the code following the loop. The while loop is used when you want to repeat a block of code based on a specific condition. It ensures that the code is executed only if the condition is true. Learn more: https://www.php.net/manual/en/control-structures.while.php

You can destroy a session in PHP by using the session_destroy() function.

  • TRUE
  • FALSE
  • nan
  • nan
In PHP, you can destroy a session by using the session_destroy() function. This function removes all session data and ends the current session. Additionally, you may need to call session_unset() to unset all session variables before calling session_destroy(). This combination ensures the complete destruction of the session. To learn more, check: http://php.net/manual/en/function.session-destroy.php

The do...while loop in PHP tests the condition before executing the block of code.

  • TRUE
  • FALSE
  • nan
  • nan
The statement is incorrect. The do...while loop in PHP executes the block of code at least once, and then checks the condition. If the condition is true, the loop continues to execute the block of code again. If the condition is false, the loop terminates. Unlike other loops, the do...while loop checks the condition after executing the block of code, ensuring that the code block executes at least once. Learn more: https://www.php.net/manual/en/control-structures.do.while.php

It's possible to have an array of arrays in PHP.

  • TRUE
  • FALSE
True. In PHP, it is possible to have an array of arrays. This is known as a multidimensional array or a nested array. Each element in the outer array can be an array itself, allowing for the creation of complex data structures. This can be useful for organizing and accessing related data in a hierarchical manner. It provides flexibility when dealing with data that requires multiple levels of grouping. Learn more: https://www.php.net/manual/en/language.types.array.php

What is the purpose of the file_put_contents() function in PHP?

  • To write data to a file
  • To read data from a file
  • To delete a file
  • To rename a file
The file_put_contents() function in PHP is used to write data to a file. It takes the file name and the data to be written as parameters and writes the data to the specified file. This function is a convenient way to write data to a file without explicitly opening and closing the file handles. Learn more: http://php.net/manual/en/function.file-put-contents.php

You are writing a PHP script and you need to store a collection of items that can be accessed by a unique key for each item. How would you do this using an associative array?

  • Declare separate variables for each item in the collection.
  • Use a loop to concatenate the items into a single string.
  • Use an indexed array to store the items in a sequential manner.
  • Use an associative array with unique keys for each item.
To store a collection of items that can be accessed by a unique key for each item, you would use an associative array in PHP. An associative array allows you to assign specific keys to each item, creating a mapping between the keys and the corresponding values. Each key-value pair represents an item in the collection, and the unique keys provide a convenient way to access and manipulate the associated values. Associative arrays are commonly used when you need to organize data based on unique identifiers or labels. Learn more: https://www.php.net/manual/en/language.types.array.php#language.types.array.syntax

PHP was originally created by ______ in the year ______.

  • James Gosling, 1995
  • Rasmus Lerdorf, 1994
  • Guido van Rossum, 1991
  • Brendan Eich, 1995
PHP was originally created by Rasmus Lerdorf in 1994. It started as a simple set of Common Gateway Interface (CGI) binaries written in the C programming language. Learn more: https://www.php.net/manual/en/history.php.php