3v4l.org

run code in 300+ PHP versions simultaneously
<?php $invalid = '{"test":"foo}'; $valid = '[]'; try { json_decode($invalid, true); // this fails silently json_decode($valid, true, 512, JSON_THROW_ON_ERROR); // Which is what Safe does to check if it needs to throw an exception if (json_last_error() !== JSON_ERROR_NONE) { var_dump('With the flag', json_last_error_msg()); } json_decode($valid, true); // Which is what Safe does to check if it needs to throw an exception if (json_last_error() !== JSON_ERROR_NONE) { var_dump('Without the flag', json_last_error_msg()); } } catch (Throwable $e) { echo 'This should not even be triggered: ' . $e->getMessage() . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 36
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 22
Found catch point at position: 37
Branch analysis from position: 37
2 jumps found. (Code = 107) Position 1 = 38, Position 2 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GX9mL
function name:  (null)
number of ops:  44
compiled vars:  !0 = $invalid, !1 = $valid, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%22test%22%3A%22foo%7D'
    4     1        ASSIGN                                                   !1, '%5B%5D'
    7     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                                 
    8     6        INIT_FCALL                                               'json_decode'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 <true>
          9        SEND_VAL                                                 512
         10        SEND_VAL                                                 4194304
         11        DO_ICALL                                                 
   11    12        INIT_FCALL                                               'json_last_error'
         13        DO_ICALL                                         $7      
         14        IS_NOT_IDENTICAL                                         $7, 0
         15      > JMPZ                                                     ~8, ->22
   12    16    >   INIT_FCALL                                               'var_dump'
         17        SEND_VAL                                                 'With+the+flag'
         18        INIT_FCALL                                               'json_last_error_msg'
         19        DO_ICALL                                         $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                                 
   15    22    >   INIT_FCALL                                               'json_decode'
         23        SEND_VAR                                                 !1
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                                 
   18    26        INIT_FCALL                                               'json_last_error'
         27        DO_ICALL                                         $12     
         28        IS_NOT_IDENTICAL                                         $12, 0
         29      > JMPZ                                                     ~13, ->36
   19    30    >   INIT_FCALL                                               'var_dump'
         31        SEND_VAL                                                 'Without+the+flag'
         32        INIT_FCALL                                               'json_last_error_msg'
         33        DO_ICALL                                         $14     
         34        SEND_VAR                                                 $14
         35        DO_ICALL                                                 
         36    > > JMP                                                      ->43
   21    37  E > > CATCH                                       last         'Throwable'
   22    38    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         39        DO_FCALL                                      0  $16     
         40        CONCAT                                           ~17     'This+should+not+even+be+triggered%3A+', $16
         41        CONCAT                                           ~18     ~17, '%0A'
         42        ECHO                                                     ~18
   23    43    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.79 ms | 1434 KiB | 17 Q