Tengo dos clases: Producto.php y Pedido.php
y tengo dos paginas web: index.php e index2.php
entonces tengo en index.php:
Código PHP:
session_start();
include_once 'classes/Pedido.php';
include_once 'classes/Producto.php';
$cart=new Pedido();
$producto=new Producto();
$producto->set_id(1);
$producto->set_nombre('p1');
$producto->set_precio('10');
$producto->set_cantidad(5);
$cart->set_pedido($producto);
$_SESSION['CART']=$cart;
Código PHP:
session_start();
include_once 'classes/Pedido.php';
include_once 'classes/Producto.php';
if(isset ($_SESSION['CART'])){
$cart=$_SESSION['CART'];
} //else $cart=new Pedido();
echo "Numero de productos: ".$cart->num_productos();
Código PHP:
Fatal error: main() [<a href='function.main'>function.main</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Pedido" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /Applications/MAMP/htdocs/SesionesPHP/index2.php on line 18