3v4l.org

run code in 500+ PHP versions simultaneously
<?php echo "Start\n"; var_dump(json_last_error()); echo "\n"; echo "Error without flag\n"; json_decode('{'); var_dump(json_last_error()); echo "\n"; echo "Clear error\n"; json_decode('true'); // clear error var_dump(json_last_error()); echo "\n"; echo "Error with flag\n"; try { json_decode('{', flags: JSON_THROW_ON_ERROR); } catch (\JsonException $e) { echo $e->getMessage(), "\n"; } var_dump(json_last_error()); echo "\n"; echo "Set different error\n"; json_decode(str_repeat('[', 1000)); var_dump(json_last_error()); echo "and check that it is not overwritten when JSON_THROW_ON_ERROR is set\n"; try { json_decode('{', flags: JSON_THROW_ON_ERROR); } catch (\JsonException $e) { echo $e->getMessage(), "\n"; } var_dump(json_last_error());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 34
Branch analysis from position: 34
2 jumps found. (Code = 107) Position 1 = 35, Position 2 = -2
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Found catch point at position: 65
Branch analysis from position: 65
2 jumps found. (Code = 107) Position 1 = 66, Position 2 = -2
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ijt3R
function name:  (null)
number of ops:  76
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ECHO                                                         'Start%0A'
    4     1        INIT_FCALL                                                   'var_dump'
          2        INIT_FCALL                                                   'json_last_error'
          3        DO_ICALL                                             $1      
          4        SEND_VAR                                                     $1
          5        DO_ICALL                                                     
    5     6        ECHO                                                         '%0A'
    7     7        ECHO                                                         'Error+without+flag%0A'
    8     8        INIT_FCALL                                                   'json_decode'
          9        SEND_VAL                                                     '%7B'
         10        DO_ICALL                                                     
    9    11        INIT_FCALL                                                   'var_dump'
         12        INIT_FCALL                                                   'json_last_error'
         13        DO_ICALL                                             $4      
         14        SEND_VAR                                                     $4
         15        DO_ICALL                                                     
   10    16        ECHO                                                         '%0A'
   12    17        ECHO                                                         'Clear+error%0A'
   13    18        INIT_FCALL                                                   'json_decode'
         19        SEND_VAL                                                     'true'
         20        DO_ICALL                                                     
   14    21        INIT_FCALL                                                   'var_dump'
         22        INIT_FCALL                                                   'json_last_error'
         23        DO_ICALL                                             $7      
         24        SEND_VAR                                                     $7
         25        DO_ICALL                                                     
   15    26        ECHO                                                         '%0A'
   17    27        ECHO                                                         'Error+with+flag%0A'
   18    28        INIT_FCALL                                                   'json_decode'
         29        SEND_VAL                                                     '%7B'
         30        SEND_VAL                                                     4194304
         31        CHECK_UNDEF_ARGS                                             
         32        DO_ICALL                                                     
         33      > JMP                                                          ->39
         34  E > > CATCH                                           last         'JsonException'
         35    >   INIT_METHOD_CALL                                             !0, 'getMessage'
         36        DO_FCALL                                          0  $10     
         37        ECHO                                                         $10
         38        ECHO                                                         '%0A'
   19    39    >   INIT_FCALL                                                   'var_dump'
         40        INIT_FCALL                                                   'json_last_error'
         41        DO_ICALL                                             $11     
         42        SEND_VAR                                                     $11
         43        DO_ICALL                                                     
   20    44        ECHO                                                         '%0A'
   22    45        ECHO                                                         'Set+different+error%0A'
   23    46        INIT_FCALL                                                   'json_decode'
         47        INIT_FCALL                                                   'str_repeat'
         48        SEND_VAL                                                     '%5B'
         49        SEND_VAL                                                     1000
         50        DO_ICALL                                             $13     
         51        SEND_VAR                                                     $13
         52        DO_ICALL                                                     
   24    53        INIT_FCALL                                                   'var_dump'
         54        INIT_FCALL                                                   'json_last_error'
         55        DO_ICALL                                             $15     
         56        SEND_VAR                                                     $15
         57        DO_ICALL                                                     
   26    58        ECHO                                                         'and+check+that+it+is+not+overwritten+when+JSON_THROW_ON_ERROR+is+set%0A'
   27    59        INIT_FCALL                                                   'json_decode'
         60        SEND_VAL                                                     '%7B'
         61        SEND_VAL                                                     4194304
         62        CHECK_UNDEF_ARGS                                             
         63        DO_ICALL                                                     
         64      > JMP                                                          ->70
         65  E > > CATCH                                           last         'JsonException'
         66    >   INIT_METHOD_CALL                                             !0, 'getMessage'
         67        DO_FCALL                                          0  $18     
         68        ECHO                                                         $18
         69        ECHO                                                         '%0A'
   28    70    >   INIT_FCALL                                                   'var_dump'
         71        INIT_FCALL                                                   'json_last_error'
         72        DO_ICALL                                             $19     
         73        SEND_VAR                                                     $19
         74        DO_ICALL                                                     
         75      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
149.69 ms | 2822 KiB | 12 Q