[thelist] [PHP Newbie] Accessing Object attributes from a _SESSION variable

Tanner Burson tanner at younet.okstate.edu
Wed Oct 29 14:05:30 CST 2003


*This message was transferred with a trial version of CommuniGate(tm) Pro*
Jacques Capesius wrote:

>print_r($_SESSION);
>echo "<br>firstname: ".$_SESSION["person"]->firstname."<br>";
>
>  
>
The problem is that PHP doesn't allow you to treat an element of the 
super global array as an object.  To fix this add:
$person_obj=$_SESSION['person'];     and then do
$person_obj->firstname             

It's just one of the little quirks in the OOP of PHP4.x hope that helps.

Tanner Burson



More information about the thelist mailing list