A variable declared outside all functions in PHP has a global scope and can be accessed anywhere in the script.
- TRUE
- FALSE
Yes, the statement is true. A variable declared outside all functions in PHP has a global scope. It means the variable is accessible from anywhere within the script, including inside functions. These global variables retain their values throughout the execution of the script. However, it is generally recommended to use global variables sparingly and follow good programming practices to avoid potential issues related to variable scoping and maintainability. Learn more: https://www.php.net/manual/en/language.variables.scope.php#language.variables.scope.global
Loading...
Related Quiz
- What is the difference between for and foreach?
- You need to generate a random number in your PHP script. What function would you use and why?
- Which of the following are true about the default keyword in a PHP switch statement?
- What can be the potential issues with using break and continue in PHP?
- You cannot modify global variables using the $GLOBALS superglobal in PHP.