3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test1() { // We have to check for existance because each call will try to define the function globally like including a file would. if (!function_exists('test2')) { function test2() { echo 'there' . PHP_EOL; } } echo 'here' . PHP_EOL; } echo "The internal method isn't defined yet: "; var_dump(function_exists('test2')); test1(); echo "Woops, function definitions don't get scoped by the function that define them. That's a feature but now we accidentally have a global function we might not have intended!: "; var_dump(function_exists('test2')); test2();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Pd4f3
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ECHO                                                     'The+internal+method+isn%27t+defined+yet%3A+'
   15     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'function_exists'
          3        SEND_VAL                                                 'test2'
          4        DO_ICALL                                         $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   16     7        INIT_FCALL                                               'test1'
          8        DO_FCALL                                      0          
   17     9        ECHO                                                     'Woops%2C+function+definitions+don%27t+get+scoped+by+the+function+that+define+them.+That%27s+a+feature+but+now+we+accidentally+have+a+global+function+we+might+not+have+intended%21%3A+'
   18    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'function_exists'
         12        SEND_VAL                                                 'test2'
         13        DO_ICALL                                         $3      
         14        SEND_VAR                                                 $3
         15        DO_ICALL                                                 
   19    16        INIT_FCALL_BY_NAME                                       'test2'
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Function test1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/Pd4f3
function name:  test1
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'test2'
          2        DO_ICALL                                         $0      
          3        BOOL_NOT                                         ~1      $0
          4      > JMPZ                                                     ~1, ->6
    7     5    >   DECLARE_FUNCTION                                         'test2'
   11     6    >   ECHO                                                     'here%0A'
   12     7      > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Pd4f3
function name:  test2
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ECHO                                                     'there%0A'
    9     1      > RETURN                                                   null

End of Dynamic Function 0

End of function test1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.6 ms | 1440 KiB | 16 Q