[ create a new paste ] login | about

Link: http://codepad.org/BtpqedEY    [ raw code | output | fork ]

PHP, pasted on Mar 6:
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
class myClass{
    public function myMethod(){// this will be lost when JSON encoding //
        echo 'Hello there!';
    }
}
$x = array('a'=>1, 'b'=>2);
$y = new myClass;
$y->a = 1;
$y->b = 2;
echo json_encode($x), "\n", json_encode($y); // identical
echo "\n", serialize($x), "\n", serialize($y); // not identical
?>


Output:
1
2
3
4
{"a":1,"b":2}
{"a":1,"b":2}
a:2:{s:1:"a";i:1;s:1:"b";i:2;}
O:7:"myClass":2:{s:1:"a";i:1;s:1:"b";i:2;}


Create a new paste based on this one


Comments: