3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public static function bar(string $label): void { echo "Callable called: $label\n"; } } class MyClass { private static string $myCallable; public function myFunc(): void { static::$myCallable = \Foo::class . '::bar'; (self::$myCallable)('this also works'); } } $myCallable = \Foo::class . '::bar'; $myCallable('calling this works!'); (new MyClass)->myFunc();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2OP8C
function name:  (null)
number of ops:  9
compiled vars:  !0 = $myCallable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, 'Foo%3A%3Abar'
   23     1        INIT_DYNAMIC_CALL                                        !0
          2        SEND_VAL_EX                                              'calling+this+works%21'
          3        DO_FCALL                                      0          
   25     4        NEW                                              $3      'MyClass'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $3, 'myFunc'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Class Foo:
Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2OP8C
function name:  bar
number of ops:  6
compiled vars:  !0 = $label
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ROPE_INIT                                     3  ~2      'Callable+called%3A+'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        ECHO                                                     ~1
    8     5      > RETURN                                                   null

End of function bar

End of class Foo.

Class MyClass:
Function myfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2OP8C
function name:  myFunc
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN_STATIC_PROP                                       'myCallable'
          1        OP_DATA                                                  'Foo%3A%3Abar'
   18     2        FETCH_STATIC_PROP_R          unknown             ~1      'myCallable'
          3        INIT_DYNAMIC_CALL                                        ~1
          4        SEND_VAL_EX                                              'this+also+works'
          5        DO_FCALL                                      0          
   19     6      > RETURN                                                   null

End of function myfunc

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.06 ms | 996 KiB | 13 Q