- serialize: documentation ( source)
<?php
class Test {
public $test;
public $test2;
public function serialize() {
return serialize($this);
}
}
$o = new Test();
$o->test = "aaaa";
$o->test2 = "bbbbb";
echo $o->serialize();