View Full Version : Setting a var to global from another function not work?

01-05-2008, 08:28 PM
Hey guys..... what am I doing wrong here? This is basically what I am doing in less code..

function foo () {
$var = $_SESSION['blah'];
$yeah = do_stuff();

function do_stuff() {
global $var;
echo $var; // Outputs ""

Ok.. I understand that the reason it's not working is because $var isn't available to the secondary function to make global because it is only available locally inside foo(); but any way to get it inside do_stuff() without passing it as an argument?


01-05-2008, 10:45 PM
no, you should pass it as an argument.