0
Php variable
variable inside a block in PHP , is having global scope?? if(1>0) { $x = 10; }
3 Réponses
+ 7
To further clarify Mickel's great answers, I'll say specifically, PHP does not support block level variable scope.
+ 4
"Any variable used inside a function is by default limited to the local function scope". That should solve your doubt. In any case, here you have much more information:
http://php.net/manual/en/language.variables.scope.php
+ 3
In the example you gave yes, the variable has a global scope and can be used outside the if statement