At 04:30 21.11.2002, Michael Wai said:
--------------------[snip]--------------------
>Hi everyone, I'm a newbie on PHP and MySQL. I've two questions that want to
>get some help.
>
>1. How to solve the problem of nested include? That's mean A include B and B
>include C.
Just do it, it works perfectly.
>2. Can I save the object in session?
Yes:
session_start();
$_SESSION['myobject'] =& $myobject;
What you need to observe is that the class MUST be declared BEFORE the
session is reloaded:
// won't work
session_start();
class A {
function A() {}
}
if (!$a) {
$a = new A();
$_SESSION['a'] =& $a;
}
Here your session is started _before_ the class gets declared. This works
for the first time, but when reloading the session object $a will be
reconstructed without the class definition readily available, so PHP will
default to a standard class. The next example will work, though:
class A {
function A() {}
}
session_start();
if (!$a) {
$a = new A();
$_SESSION['a'] =& $a;
}
As you can see the class decl is given _before_ the session is started.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php