3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_val_as_array($val) { $type = gettype($val); try { echo "val before access = ".var_export($val, true)."\n"; echo "accessing $type as array {$val['test']}\n"; $val['test'] = 'wtf'; echo "set $type offset 'test' to string 'wtf'\n"; echo "$type offset 'test' = {$val['test']}\n"; echo "val after access = ".var_export($val, true)."\n"; } catch (Exception $e) { echo "caught error {$e->getMessage()} when accessing $type as array\n"; } }; test_val_as_array(null); test_val_as_array('test'); test_val_as_array(123); test_val_as_array(true); test_val_as_array(1.2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F8EOY
function name:  (null)
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'test_val_as_array'
          1        SEND_VAL                                                 null
          2        DO_FCALL                                      0          
   18     3        INIT_FCALL                                               'test_val_as_array'
          4        SEND_VAL                                                 'test'
          5        DO_FCALL                                      0          
   19     6        INIT_FCALL                                               'test_val_as_array'
          7        SEND_VAL                                                 123
          8        DO_FCALL                                      0          
   20     9        INIT_FCALL                                               'test_val_as_array'
         10        SEND_VAL                                                 <true>
         11        DO_FCALL                                      0          
   21    12        INIT_FCALL                                               'test_val_as_array'
         13        SEND_VAL                                                 1.2
         14        DO_FCALL                                      0          
         15      > RETURN                                                   1

Function test_val_as_array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
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/F8EOY
function name:  test_val_as_array
number of ops:  47
compiled vars:  !0 = $val, !1 = $type, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        GET_TYPE                                         ~3      !0
          2        ASSIGN                                                   !1, ~3
    6     3        INIT_FCALL                                               'var_export'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $5      
          7        CONCAT                                           ~6      'val+before+access+%3D+', $5
          8        CONCAT                                           ~7      ~6, '%0A'
          9        ECHO                                                     ~7
    7    10        ROPE_INIT                                     5  ~10     'accessing+'
         11        ROPE_ADD                                      1  ~10     ~10, !1
         12        ROPE_ADD                                      2  ~10     ~10, '+as+array+'
         13        FETCH_DIM_R                                      ~8      !0, 'test'
         14        ROPE_ADD                                      3  ~10     ~10, ~8
         15        ROPE_END                                      4  ~9      ~10, '%0A'
         16        ECHO                                                     ~9
    8    17        ASSIGN_DIM                                               !0, 'test'
         18        OP_DATA                                                  'wtf'
    9    19        ROPE_INIT                                     3  ~15     'set+'
         20        ROPE_ADD                                      1  ~15     ~15, !1
         21        ROPE_END                                      2  ~14     ~15, '+offset+%27test%27+to+string+%27wtf%27%0A'
         22        ECHO                                                     ~14
   10    23        ROPE_INIT                                     4  ~19     !1
         24        ROPE_ADD                                      1  ~19     ~19, '+offset+%27test%27+%3D+'
         25        FETCH_DIM_R                                      ~17     !0, 'test'
         26        ROPE_ADD                                      2  ~19     ~19, ~17
         27        ROPE_END                                      3  ~18     ~19, '%0A'
         28        ECHO                                                     ~18
   11    29        INIT_FCALL                                               'var_export'
         30        SEND_VAR                                                 !0
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $21     
         33        CONCAT                                           ~22     'val+after+access+%3D+', $21
         34        CONCAT                                           ~23     ~22, '%0A'
         35        ECHO                                                     ~23
         36      > JMP                                                      ->46
   12    37  E > > CATCH                                       last         'Exception'
   13    38    >   ROPE_INIT                                     5  ~26     'caught+error+'
         39        INIT_METHOD_CALL                                         !2, 'getMessage'
         40        DO_FCALL                                      0  $24     
         41        ROPE_ADD                                      1  ~26     ~26, $24
         42        ROPE_ADD                                      2  ~26     ~26, '+when+accessing+'
         43        ROPE_ADD                                      3  ~26     ~26, !1
         44        ROPE_END                                      4  ~25     ~26, '+as+array%0A'
         45        ECHO                                                     ~25
   15    46    > > RETURN                                                   null

End of function test_val_as_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.45 ms | 1403 KiB | 20 Q