note 39330 added to function.is-object

From: Date: Sun, 25 Jan 2004 00:56:05 +0000
Subject: note 39330 added to function.is-object
Groups: php.notes 
Request: Send a blank email to php-notes+get-64126@lists.php.net to get a copy of this message
not always returns is_object() a value... object itself must be loaded... ############################ //in include.php class foo{ } ############################# ############################# // index.php //wrong one $foo=$HTTP_SESSION_VARS["var"];//get it require 'include.php';//load object echo"foo is a:".$foo." and is_object returns:".is_object($foo)."<br>"; //returns "foo is a:Object and is_object returns:" if(is_object($foo)){ echo "object from session<br>"; } else { $foo= new foo(); echo "new object<br>"; } $HTTP_SESSION_VARS["var"]=$foo;//set it ####################### ####################### // index.php //right one require 'include.php';//load object $foo=$HTTP_SESSION_VARS["var"];//get it echo"foo is a:".$foo." and is_object returns:".is_object($foo)."<br>"; //returns "foo is a:Object and is_object returns:1" if(is_object($foo)){ echo "object from session<br>"; } else { $foo= new foo(); echo "new object<br>"; } $HTTP_SESSION_VARS["var"]=$foo;//set it ######################### serialize is another solution:) ---- Manual Page -- http://www.php.net/manual/en/function.is-object.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39330 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39330&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39330&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64126) next »