3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace { const CONSTANT = 'GLOBAL'; var_dump($closure); $closure = function () { return CONSTANT; }; $closure = $closure->bindTo(null, 'Foo\\Scope'); $closure(); $closure = $closure->bindTo(null, 'Bar\\Scope'); $closure(); } namespace Foo { const CONSTANT = __NAMESPACE__; class Scope {} } namespace Bar { const CONSTANT = __NAMESPACE__; class Scope {} }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D2XO4
function name:  (null)
number of ops:  23
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CONST                                            'CONSTANT', 'GLOBAL'
    5     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
    7     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FD2XO4%3A7%240'
          5        ASSIGN                                                   !0, ~2
   11     6        INIT_METHOD_CALL                                         !0, 'bindTo'
          7        SEND_VAL_EX                                              null
          8        SEND_VAL_EX                                              'Foo%5CScope'
          9        DO_FCALL                                      0  $4      
         10        ASSIGN                                                   !0, $4
   12    11        INIT_DYNAMIC_CALL                                        !0
         12        DO_FCALL                                      0          
   13    13        INIT_METHOD_CALL                                         !0, 'bindTo'
         14        SEND_VAL_EX                                              null
         15        SEND_VAL_EX                                              'Bar%5CScope'
         16        DO_FCALL                                      0  $7      
         17        ASSIGN                                                   !0, $7
   14    18        INIT_DYNAMIC_CALL                                        !0
         19        DO_FCALL                                      0          
   19    20        DECLARE_CONST                                            'Foo%5CCONSTANT', 'Foo'
   25    21        DECLARE_CONST                                            'Bar%5CCONSTANT', 'Bar'
   28    22      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FD2XO4%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D2XO4
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_CONSTANT                                   ~0      'CONSTANT'
          1      > RETURN                                                   ~0
    9     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FD2XO4%3A7%240

Class Foo\Scope: [no user functions]
Class Bar\Scope: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.77 ms | 1396 KiB | 15 Q