I'm trying to pass a serializado
object to a form, to pick it up and not have to re-create it on the next page, but I do not print the string correctly in the input
that I'm printing on. My code is as follows:
class Objeto{
public $id;
public $nombre;
public $atributos;
public function __construct($id, $nombre, $atributos){
$this->id=$id;
$this->nombre=$nombre;
$this->atributos=$atributos;
}
}
$objeto= new Objeto(32,'camiseta','de color verde');
$serializado=serialize($objeto);
?>
Then I have a form in which I print the serialized object:
<form method="post" action="pasando-serializado.php" >
<input type="text" name="serializado" value="<?php echo $cadena;?>" lenght=1000 style="width: 50%"/>
<button type="submit">Enviar</button>
</form>
And finally a file in which I pick up the post of the form:
$serializado=$_POST['serializado'];
$unserializado=unserialize($serializado);
echo '<pre>';
var_dump($unserializado);
echo '</pre>';
It returns the value "O: 6".
Does anyone know why this happens? It is assumed that if what you return the serialize
is a chain you should be able to print where you want, right?
Thank you very much for your help ;-)