note 39330 deleted from function.is-object by tomsommer
| From: | tomsommer@php.net | Date: | Wed, 19 May 2004 06:27:32 +0000 |
| Subject: | note 39330 deleted from function.is-object by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69816@lists.php.net to get a copy of this message | ||
Note Submitter:
----
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:)