Hi,
Just wondering about the OOP aspect of PHP. Say I create an object from a class in one PHP page - can I pass it to another PHP page through POST or GET, or do I have to recreate the object from the class again?
Thanks in advance!
Persistent objects in PHP?
Moderator: General Moderators
-
LonelyProgrammer
- Forum Contributor
- Posts: 108
- Joined: Sun Oct 12, 2003 7:10 am
You could serialize() the object and pass it via GET/POST but it can be quite ugly. It's better to store the object in a session, like $_SESSION['obj'] = $obj;
When storing objects in sessions don't forget you must define the class before session_start(), i.e include 'theclassfile.php'; session_start() and not session_start(); include 'theclassfile.php';

When storing objects in sessions don't forget you must define the class before session_start(), i.e include 'theclassfile.php'; session_start() and not session_start(); include 'theclassfile.php';
-
jollyjumper
- Forum Contributor
- Posts: 107
- Joined: Sat Jan 25, 2003 11:03 am
-
jollyjumper
- Forum Contributor
- Posts: 107
- Joined: Sat Jan 25, 2003 11:03 am