Hay guys. I\'m kinda new to OOP in PHP. I\'ve learnt how to write and create objects. Is there a way to take an object and pass it to another script? either using GET or POS
Here is an example with autoloading in respect to the answer by Tom Haigh:
Before you start the session:
function __autoload($className) {
$file = PATH_TO_FOLDER_WITH_ALL_CLASS_FILES."/".$className.'.php';
if(file_exists($file)) {
require_once $file;
}
}
session_start();
Page passing the object:
$object = new class();
$object->someProperty = 'hello';
//store in session
$_SESSION['object'] = $object;
Page receiving the object:
$object = $_SESSION['object'];
//add something else, which will be stored in the session
$object->anotherPropery = 'Something';
The autoload method will automatically load the objects while you retrieve data from session.