3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace { const CONSTANT = 'GLOBAL'; $closure = function () { var_dump(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/ZcjFb
function name:  (null)
number of ops:  20
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CONST                                            'CONSTANT', 'GLOBAL'
    6     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZcjFb%3A6%240'
          2        ASSIGN                                                   !0, ~1
   10     3        INIT_METHOD_CALL                                         !0, 'bindTo'
          4        SEND_VAL_EX                                              null
          5        SEND_VAL_EX                                              'Foo%5CScope'
          6        DO_FCALL                                      0  $3      
          7        ASSIGN                                                   !0, $3
   11     8        INIT_DYNAMIC_CALL                                        !0
          9        DO_FCALL                                      0          
   12    10        INIT_METHOD_CALL                                         !0, 'bindTo'
         11        SEND_VAL_EX                                              null
         12        SEND_VAL_EX                                              'Bar%5CScope'
         13        DO_FCALL                                      0  $6      
         14        ASSIGN                                                   !0, $6
   13    15        INIT_DYNAMIC_CALL                                        !0
         16        DO_FCALL                                      0          
   18    17        DECLARE_CONST                                            'Foo%5CCONSTANT', 'Foo'
   24    18        DECLARE_CONST                                            'Bar%5CCONSTANT', 'Bar'
   27    19      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FZcjFb%3A6%240

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.89 ms | 1395 KiB | 15 Q