<?php
function foo($one, $two){
bar($one);
}
function bar($one){
echo $one;
//How do I access $two from the parent function scope?
}
?>
If I have the code above, how can I access the variable $two from within bar(), without passing it in as a variable (for reasons unknown).
Thanks,
Mike
Make a class - you can declare $two as an instance field which will be accessible to all instance methods:
I do use $global to access variables in my entire script.
Like this:
A crude way is to export it into global scope, for example: