3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Создаю массив вне рендера $cmd_outputs = [ '1-1' => 'Привет' ]; function func($cmd_outputs) { // Тут почему-то происходит ошибка var_export($cmd_outputs['1-1']); }; function f() { // Поэтому объявляю global global $cmd_outputs; // Тут все хорошо var_export($cmd_outputs['1-1']); func($cmd_outputs); return 'ok'; }; f();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RZCjG
function name:  (null)
number of ops:  4
compiled vars:  !0 = $cmd_outputs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'f'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function func:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RZCjG
function name:  func
number of ops:  6
compiled vars:  !0 = $cmd_outputs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'var_export'
          2        FETCH_DIM_R                                      ~1      !0, '1-1'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
   11     5      > RETURN                                                   null

End of function func

Function f:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RZCjG
function name:  f
number of ops:  10
compiled vars:  !0 = $cmd_outputs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   BIND_GLOBAL                                              !0, 'cmd_outputs'
   17     1        INIT_FCALL                                               'var_export'
          2        FETCH_DIM_R                                      ~1      !0, '1-1'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
   18     5        INIT_FCALL                                               'func'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0          
   19     8      > RETURN                                                   'ok'
   20     9*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
244.66 ms | 1002 KiB | 16 Q