You cannot modify global variables using the $GLOBALS superglobal in PHP.
- FALSE
- TRUE
The correct option is 2. You can modify global variables using the $GLOBALS superglobal in PHP. The $GLOBALS array provides references to all global variables, allowing you to retrieve their values and modify them directly. By accessing specific elements using their names as keys in the $GLOBALS array, you can update the values of global variables from anywhere within the script. However, it is generally recommended to use caution when modifying global variables, as excessive reliance on them can lead to code complexity and potential issues. It is often preferable to utilize other techniques, such as passing variables as function parameters or using object-oriented design principles, to achieve better code organization and maintainability. Learn more: https://www.php.net/manual/en/reserved.variables.globals.php
Loading...
Related Quiz
- The && operator in PHP is an example of a ______ operator.
- How can we display information of a variable and readable by a human with PHP?
- How can you encode a PHP array into a JSON object?
- A common use case for the $GLOBALS superglobal in PHP is to access global variables from within a function, which would otherwise be out of the function's ______.
- What are some commonly used miscellaneous functions in PHP?