Auth - losing context
| From: | Ed Greenberg | Date: | Thu, 07 Jul 2005 05:27:52 +0000 |
| Subject: | Auth - losing context | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19886@lists.php.net to get a copy of this message | ||
This may be a more general OO question than an Auth question, but I hope somebody will know the answer.
Up at the top of my script, I do:
$a=new Auth(...)
Later on, I instantiate a class and call one of it's methods.
Down in the method, I need to do a checkLogin() to see if the user is logged in. Then I'm going to do a getUsername().
well, $a is out of context since I'm in a method, but it's there in $GLOBALS, so I do
$a=&$GLOBALS['a'];
$loggedin = $a->checkLogin();
What I get is 'call to undefined function: checklogin()'
I can see the object's members in the debugger (Zend) but what happened to it's binding to it's code?
There must be a better way that I'm missing. Does anybody know?
Thanks,
</edg>