3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = null; echo "Should throw a notice when trying to access an element in a non-array data type \n"; $should_throw_notice = 'foo' === $arr['key']; echo "\n=======\n\n"; echo "Should NOT throw a notice when setting an element in a non-array data type. PHP should type juggle from `null` to `array`.\n\n"; $arr['key'] = 'foo'; var_dump( $arr );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m1QUYX
function name:  (null)
number of ops:  13
compiled vars:  !0 = $arr, !1 = $should_throw_notice
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, null
    5     1        ECHO                                                     'Should+throw+a+notice+when+trying+to+access+an+element+in+a+non-array+data+type+%0A'
    6     2        FETCH_DIM_R                                      ~3      !0, 'key'
          3        IS_IDENTICAL                                     ~4      ~3, 'foo'
          4        ASSIGN                                                   !1, ~4
    8     5        ECHO                                                     '%0A%3D%3D%3D%3D%3D%3D%3D%0A%0A'
   10     6        ECHO                                                     'Should+NOT+throw+a+notice+when+setting+an+element+in+a+non-array+data+type.+PHP+should+type+juggle+from+%60null%60+to+%60array%60.%0A%0A'
   11     7        ASSIGN_DIM                                               !0, 'key'
          8        OP_DATA                                                  'foo'
   12     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.31 ms | 943 KiB | 14 Q