Which of the following statements about variable scope in PHP are correct?
- Local variables declared inside a function are destroyed after the function finishes execution.
- Global variables declared outside functions retain their values throughout the script execution.
- Local variables can only be accessed within the function in which they are declared.
- All of the above
All of the given statements about variable scope in PHP are correct. Local variables declared inside a function are destroyed after the function finishes execution. Global variables declared outside functions retain their values throughout the script execution. Local variables can only be accessed within the function in which they are declared. Learn more: https://www.php.net/manual/en/language.variables.scope.php
Loading...
Related Quiz
- What PHP function can be used to write to a file?
- Which of the following is a comparison operator in PHP?
- What can be potential issues when working with multidimensional arrays in PHP?
- You have a PHP script and you need to get data sent in the URL's query string. How would you do this using the $_REQUEST superglobal?
- What is a function in PHP?