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

Leave a comment

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