function scope
Guilty Of PHP articles about function scope
2 articles
-
Declare PHP Constants and Read Them Alongside Variables in Functions
Use one example to compare a reassigned variable with constants declared by const and define(), then see how the function uses global for the variable but not the constants.
-
Understand PHP execution and behavior
Where Can You Read a PHP Variable After a Loop or Function?
An if statement or loop leaves variables in the surrounding scope, while a function has its own scope. Examples show how to pass values in, bind them in an arrow function, and retain a static local.
