I'm sorry if this has been answered before - I searched but couldn't find a definitive answer.
If I have a function foo()
that deals with a variable $x
, and then a subfunction bar()
, how can I access $x
?
function foo(){
$x = 0;
function bar(){
//do something with $x
}
}
Is this code correct, or is there better practice for accessing the variables in a parent function?