3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo\Bar\Baz { $closureBeforeDefined = function () { return relativeFunction(); }; var_dump($closureBeforeDefined());} namespace { function relativeFunction() { return 'IN GLOBAL NAMESPACE'; } } namespace Foo\Bar\Baz { function relativeFunction() { return 'IN RELATIVE NAMESPACE'; } $closureAfterDefined = function () { return relativeFunction(); }; var_dump($closureBeforeDefined()); var_dump($closureAfterDefined()); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCA5L
function name:  (null)
number of ops:  20
compiled vars:  !0 = $closureBeforeDefined, !1 = $closureAfterDefined
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00foo%5Cbar%5Cbaz%5C%7Bclosure%7D%2Fin%2FYCA5L%3A5%240'
          1        ASSIGN                                                   !0, ~2
    8     2        INIT_NS_FCALL_BY_NAME                                    'Foo%5CBar%5CBaz%5Cvar_dump'
          3        INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0  $4      
          5        SEND_VAR_NO_REF_EX                                       $4
          6        DO_FCALL                                      0          
   23     7        DECLARE_LAMBDA_FUNCTION                                  '%00foo%5Cbar%5Cbaz%5C%7Bclosure%7D%2Fin%2FYCA5L%3A23%241'
          8        ASSIGN                                                   !1, ~6
   27     9        INIT_NS_FCALL_BY_NAME                                    'Foo%5CBar%5CBaz%5Cvar_dump'
         10        INIT_DYNAMIC_CALL                                        !0
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR_NO_REF_EX                                       $8
         13        DO_FCALL                                      0          
   28    14        INIT_NS_FCALL_BY_NAME                                    'Foo%5CBar%5CBaz%5Cvar_dump'
         15        INIT_DYNAMIC_CALL                                        !1
         16        DO_FCALL                                      0  $10     
         17        SEND_VAR_NO_REF_EX                                       $10
         18        DO_FCALL                                      0          
   29    19      > RETURN                                                   1

Function %00foo%5Cbar%5Cbaz%5C%7Bclosure%7D%2Fin%2FYCA5L%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCA5L
function name:  Foo\Bar\Baz\{closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_NS_FCALL_BY_NAME                                    'Foo%5CBar%5CBaz%5CrelativeFunction'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
    7     3*     > RETURN                                                   null

End of function %00foo%5Cbar%5Cbaz%5C%7Bclosure%7D%2Fin%2FYCA5L%3A5%240

Function relativefunction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCA5L
function name:  relativeFunction
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   'IN+GLOBAL+NAMESPACE'
   13     1*     > RETURN                                                   null

End of function relativefunction

Function foo%5Cbar%5Cbaz%5Crelativefunction:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCA5L
function name:  Foo\Bar\Baz\relativeFunction
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E > > RETURN                                                   'IN+RELATIVE+NAMESPACE'
   21     1*     > RETURN                                                   null

End of function foo%5Cbar%5Cbaz%5Crelativefunction

Function %00foo%5Cbar%5Cbaz%5C%7Bclosure%7D%2Fin%2FYCA5L%3A23%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YCA5L
function name:  Foo\Bar\Baz\{closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_NS_FCALL_BY_NAME                                    'Foo%5CBar%5CBaz%5CrelativeFunction'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   25     3*     > RETURN                                                   null

End of function %00foo%5Cbar%5Cbaz%5C%7Bclosure%7D%2Fin%2FYCA5L%3A23%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.47 ms | 1403 KiB | 17 Q