eval.in

Paste #2907

PHP — PHP 5.4.6, pasted 1 year ago

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<?php

$test = new StdClass();
$test->id = 1;
$test->content = 'something';
$test->completed = false;

$encoded = json_encode($test);

print('<pre>');var_dump($encoded);print('</pre>');
print('<pre>');var_dump(json_decode($encoded));print('</pre>');

Program Output

<pre>string(48) "{"id":1,"content":"something","completed":false}"
</pre><pre>object(stdClass)#2 (3) {
  ["id"]=>
  int(1)
  ["content"]=>
  string(9) "something"
  ["completed"]=>
  bool(false)
}
</pre>

OK (0.004 sec real, 0.005 sec wall, 13 MB, 75 syscalls)

Fork