"Fossies" - the Fresh Open Source Software Archive

Member "php-7.4.1/ext/json/tests/001.phpt" (17 Dec 2019, 1316 Bytes) of package /linux/www/php-7.4.1.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 --TEST--
    2 json_decode() tests
    3 --SKIPIF--
    4 <?php if (!extension_loaded("json")) print "skip"; ?>
    5 --FILE--
    6 <?php
    7 
    8 var_dump(json_decode());
    9 var_dump(json_decode(""));
   10 var_dump(json_decode("", 1));
   11 var_dump(json_decode("", 0));
   12 var_dump(json_decode(".", 1));
   13 var_dump(json_decode(".", 0));
   14 var_dump(json_decode("<?>"));
   15 var_dump(json_decode(";"));
   16 var_dump(json_decode("руссиш"));
   17 var_dump(json_decode("blah"));
   18 var_dump(json_decode(NULL));
   19 var_dump(json_decode('{ "test": { "foo": "bar" } }'));
   20 var_dump(json_decode('{ "test": { "foo": "" } }'));
   21 var_dump(json_decode('{ "": { "foo": "" } }'));
   22 var_dump(json_decode('{ "": { "": "" } }'));
   23 var_dump(json_decode('{ "": { "": "" }'));
   24 var_dump(json_decode('{ "": "": "" } }'));
   25 
   26 ?>
   27 ===DONE===
   28 --EXPECTF--
   29 Warning: json_decode() expects at least 1 parameter, 0 given in %s on line %d
   30 NULL
   31 NULL
   32 NULL
   33 NULL
   34 NULL
   35 NULL
   36 NULL
   37 NULL
   38 NULL
   39 NULL
   40 NULL
   41 object(stdClass)#%d (1) {
   42   ["test"]=>
   43   object(stdClass)#%d (1) {
   44     ["foo"]=>
   45     string(3) "bar"
   46   }
   47 }
   48 object(stdClass)#%d (1) {
   49   ["test"]=>
   50   object(stdClass)#%d (1) {
   51     ["foo"]=>
   52     string(0) ""
   53   }
   54 }
   55 object(stdClass)#%d (1) {
   56   [""]=>
   57   object(stdClass)#%d (1) {
   58     ["foo"]=>
   59     string(0) ""
   60   }
   61 }
   62 object(stdClass)#%d (1) {
   63   [""]=>
   64   object(stdClass)#%d (1) {
   65     [""]=>
   66     string(0) ""
   67   }
   68 }
   69 NULL
   70 NULL
   71 ===DONE===