<?php show_source(end(explode('/',$_SERVER['PHP_SELF']))); echo "<hr>"; ?>
<?php
class User{
private $name;
private $id;
public function __construct($name, $id){
$this->setName($name);
$this->setId($id);
}
public function setName($name){
$this->name = $name;
}
public function getName(){
return $this->name;
}
public function setId($id){
$this->id = $id;
}
public function getId(){
return $this->id;
}
}
$me = new User('Toby Boudreaux', 'tobyjoe', 1001);
$serialized = serialize($me);
echo "$serialized\r\n";
$new_me = unserialize($serialized);
print_r($new_me);
?>
O:4:"User":2:{s:10:" User name";s:14:"Toby Boudreaux";s:8:" User id";s:7:"tobyjoe";}
User Object
(
[name:User:private] => Toby Boudreaux
[id:User:private] => tobyjoe
)