Arquivos
hhvm/hphp/test/zend/bad/ext-json/json_decode_basic.php
T
2013-04-23 12:58:59 -07:00

42 linhas
927 B
PHP

<?php
/* Prototype : mixed json_decode ( string $json [, bool $assoc ] )
* Description: Decodes a JSON string
* Source code: ext/json/php_json.c
* Alias to functions:
*/
echo "*** Testing json_decode() : basic functionality ***\n";
// array with different values for $string
$inputs = array (
'0',
'123',
'-123',
'2147483647',
'-2147483648',
'123.456',
'1230',
'-1230',
'true',
'false',
'null',
'"abc"',
'"Hello World\r\n"',
'[]',
'[1,2,3,4,5]',
'{"myInt":99,"myFloat":123.45,"myNull":null,"myBool":true,"myString":"Hello World"}',
'{"Jan":31,"Feb":29,"Mar":31,"April":30,"May":31,"June":30}',
'""',
'{}'
);
// loop through with each element of the $inputs array to test json_decode() function
$count = 1;
foreach($inputs as $input) {
echo "-- Iteration $count --\n";
var_dump(json_decode($input));
var_dump(json_decode($input, TRUE));
$count ++;
}
?>
===Done===