global $var; Is Not Working!??!
Posted: Mon Aug 22, 2005 11:26 pm
Why does this work...
but... if I try to access $moo from inside a function:
I've just started using this box to code php (Ubuntu v5.04) and due to it's ease of use, I'm also using xampp (http://www.apachefriends.org/en/xampp-linux.html), I'm using php v5.0.4 (heh nice coincidence)...
I've never seen anything like this on any other box I've used (all winxp), I can just create the object inside the function, but that's a pita... especially for the db class...
...help!
Code: Select all
class meh {
function bah(){
echo "whoo?";
}
}
$moo = new meh();
$moo->bah();
Output, As Expected: "whoo?"Code: Select all
class meh {
function bah(){
echo "whoo?";
}
}
$moo = new meh();
function meee(){
global $moo;
$moo->bah();
}
meee();
Output, not quite expected...:
"Fatal error: Call to a member function bah() on a non-object in /var/www/blahblahblah.php on line huh?"I've never seen anything like this on any other box I've used (all winxp), I can just create the object inside the function, but that's a pita... especially for the db class...
...help!