3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = json_encode( array( 1 => array( 'English' => array( 'One', 'January' ), 'French' => array( 'Une', 'Janvier' ) ) ) ); // Define the errors. $constants = get_defined_constants(true); $json_errors = array(); foreach ($constants["json"] as $name => $value) { if (!strncmp($name, "JSON_ERROR_", 11)) { $json_errors[$value] = $name; } } // Show the errors for different depths. foreach (range(4, 3, -1) as $depth) { var_dump(json_decode($json, true, $depth)); echo 'Last error: ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 22
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 47
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 47
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 23
filename:       /in/q7bFb
function name:  (null)
number of ops:  49
compiled vars:  !0 = $json, !1 = $constants, !2 = $json_errors, !3 = $value, !4 = $name, !5 = $depth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'json_encode'
    6     1        SEND_VAL                                                 <array>
          2        DO_ICALL                                         $6      
    2     3        ASSIGN                                                   !0, $6
   18     4        INIT_FCALL                                               'get_defined_constants'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
   19     8        ASSIGN                                                   !2, <array>
   20     9        FETCH_DIM_R                                      ~11     !1, 'json'
         10      > FE_RESET_R                                       $12     ~11, ->23
         11    > > FE_FETCH_R                                       ~13     $12, !3, ->23
         12    >   ASSIGN                                                   !4, ~13
   21    13        INIT_FCALL                                               'strncmp'
         14        SEND_VAR                                                 !4
         15        SEND_VAL                                                 'JSON_ERROR_'
         16        SEND_VAL                                                 11
         17        DO_ICALL                                         $15     
         18        BOOL_NOT                                         ~16     $15
         19      > JMPZ                                                     ~16, ->22
   22    20    >   ASSIGN_DIM                                               !2, !3
         21        OP_DATA                                                  !4
   20    22    > > JMP                                                      ->11
         23    >   FE_FREE                                                  $12
   27    24        INIT_FCALL                                               'range'
         25        SEND_VAL                                                 4
         26        SEND_VAL                                                 3
         27        SEND_VAL                                                 -1
         28        DO_ICALL                                         $18     
         29      > FE_RESET_R                                       $19     $18, ->47
         30    > > FE_FETCH_R                                               $19, !5, ->47
   28    31    >   INIT_FCALL                                               'var_dump'
         32        INIT_FCALL                                               'json_decode'
         33        SEND_VAR                                                 !0
         34        SEND_VAL                                                 <true>
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                         $20     
         37        SEND_VAR                                                 $20
         38        DO_ICALL                                                 
   29    39        ECHO                                                     'Last+error%3A+'
         40        INIT_FCALL                                               'json_last_error'
         41        DO_ICALL                                         $22     
         42        FETCH_DIM_R                                      ~23     !2, $22
         43        ECHO                                                     ~23
         44        ECHO                                                     '%0A'
         45        ECHO                                                     '%0A'
   27    46      > JMP                                                      ->30
         47    >   FE_FREE                                                  $19
   30    48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.91 ms | 1392 KiB | 27 Q