3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { public const NAME = 'Serkan'; } class PhpSpec { public function __construct($name) { $func = function($name) { return constant(get_class($this) . '::' . $name); }; $closure = $func->bindTo(new Person()); echo $closure($name); } } $spe = new PhpSpec('NAME');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KVs37
function name:  (null)
number of ops:  5
compiled vars:  !0 = $spe
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'PhpSpec'
          1        SEND_VAL_EX                                              'NAME'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
          4      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FKVs37%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KVs37
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'constant'
          2        FETCH_THIS                                       ~1      
          3        GET_CLASS                                        ~2      ~1
          4        CONCAT                                           ~3      ~2, '%3A%3A'
          5        CONCAT                                           ~4      ~3, !0
          6        SEND_VAL                                                 ~4
          7        DO_ICALL                                         $5      
          8      > RETURN                                                   $5
   13     9*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FKVs37%3A11%240

Class Person: [no user functions]
Class PhpSpec:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KVs37
function name:  __construct
number of ops:  14
compiled vars:  !0 = $name, !1 = $func, !2 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FKVs37%3A11%240'
          2        ASSIGN                                                   !1, ~3
   15     3        INIT_METHOD_CALL                                         !1, 'bindTo'
          4        NEW                                              $5      'Person'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $5
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !2, $7
   17     9        INIT_DYNAMIC_CALL                                        !2
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $9      
         12        ECHO                                                     $9
   18    13      > RETURN                                                   null

End of function __construct

End of class PhpSpec.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.99 ms | 1396 KiB | 15 Q