Re: [phplib] page_open inside a Class From: Layne Weathers (layne <email protected>)
Date: 08/17/01

> class CTS {
>
> function CTS($perm_level) {
> page_open(array("sess" => "CtsSession",
> "auth" => "CtsCryptAuth",
> "perm" => "CtsPerm"));
> // echo get_class($perm); //why does this print 'true'
> $perm->check("$perm_level");
> }
> }
>
> The above code produces the following error:
>
> Fatal error: Call to a member function on a non-object in
> CTS/CTS.php on line 36
>
> I have tried changing $perm->check to $this->perm->check and
> have tried
> declaring the $sess, $auth, and $perm variables as globals, with no
> success.

I would guess that even though you are calling page_open from your
constructor, the PHPLib objects are being created in the global scope. I
would try something like:

        function CTS($perm_level) {
                global $sess, $auth, $perm;
                page_open(array("sess" => "CtsSession",
                        "auth" => "CtsCryptAuth",
                        "perm" => "CtsPerm"));
                $this->sess = $sess;
                $this->auth = $auth;
                $this->perm = $perm;
                $this->perm->check($perm_level);
        }

Layne Weathers
Ifworld Inc

-- 
Abbestellen mit Mail an:   phplib-unsubscribe <email protected>
Kommandoliste mit Mail an: phplib-help <email protected>