PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
function test1()
{
$count=0;
function test2()
{
$count=1;
print($count);
}
test2();
}
print(test1());
?>
in function test2(), is it possible to access variable $count of function test1(). Because I have to check value of variable of parent function while using recursion.
Kieran Huggins wrote:Check out "passing variables by association" - it might be just what you're looking for.
what does it mean by "passing variables by association"?as i know variables can be send to a function either passing by value or by reference. is it another way to pass variables to functions? how ?
webspider wrote:what does it mean by "passing variables by association"?as i know variables can be send to a function either passing by value or by reference. is it another way to pass variables to functions? how ?
I've no idea what that is either.
You probably won't need to pass by reference though since you could always just return a value, and you definitely won't need to define that function within another, especially if recursion is what you're after.