note 60926 deleted from ref.session by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 15:56:07 +0000 |
| Subject: | note 60926 deleted from ref.session by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134304@lists.php.net to get a copy of this message | ||
Note Submitter: pascal.fr => gmail.com
----
If you have saved an object in session, you must define the class of the object before the
session_start().
If you don't do that, php will not know the class of the object, and his type will be
"__PHP_Incomplete_Class".
This:
<?php
session_start();
class Foo{
var $fooVar = 'Hello world !!!';
}
$myFoo = new Foo();
$_SESSION['myFoo'] = $myFoo;
echo 'Save in session';
?>
define the Foo class and save an instance in session.
<?php
session_start();
echo '<pre>';
print_r( $_SESSION ); // don't know the Foo class...
echo '</pre>';
?>
will print :
Array
(
[myFoo] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => foo
[fooVar] => Hello world !!!
)
)