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
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *