вторник, 28 февраля 2012 г.

echo serialize($x)."
";

class z
{
public $name;
public function __construct($name)
{
$this -> name = $name;
}
public function tellname()
{
echo $this -> name;
}
}

$student = new z('Vasja');
print_r($student); 
echo "<br>";
$pack = serialize($student);
print_r($pack);
echo "<br>";
$new_student = unserialize($pack);
$new_student -> tellname();

echo "<hr>";

$man = new z('Max');
$json = json_encode($man);
print_r($json);
$new_man = json_decode($json);
//$new_man -> tellname();

echo "<hr>";

$x = array (1,3,true, 'max', array (6,2,array('a'=>'AAA','b'=>'BBB'),'Dima','Anja'));
echo "<pre>";
print_r($x);
echo "</pre>";

echo serialize($x)."<br>";
echo "<hr>";
$f = json_encode($x);
echo $f;
$f = json_decode($f);
echo "<pre>";
print_r($f);
echo "</pre>";

echo $f[4][2] -> a ;

Комментариев нет:

Отправить комментарий