0

Static scoping : The function sees the variable from parent function first. Dynamic scoping : The function sees the variable from the function that calls the current function first.

Is there these kind of concepts in PHP? Thank you for your reply!

GGG
  • 629
  • 1
  • 5
  • 7
  • 1
    Simple google seartch et voila: http://php.net/manual/en/language.variables.scope.php – Erik Oct 24 '17 at 04:15

1 Answers1

0

These concepts do not exist in PHP. Every function has its own scope.

Therefore PHP has a function scope. That means: functions do only have access to their own variables (the variables declared inside the function, or function params) and code outside of functions does only have access to variables that are declared outside functions. (You can declare variables global to access them inside functions - but thats not recommended.)

If you want to know more about the PHP variable scope read this answer from deceze. He made a good job explaining this topic here: https://stackoverflow.com/a/16959577

Community
  • 1
  • 1
Aphelion
  • 16
  • 1