"Fossies" - the Fresh Open Source Software Archive

Member "php-8.0.28-src/ext/json/tests/001.phpt" (14 Feb 2023, 1121 Bytes) of package /windows/www/php-8.0.28-src.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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