3v4l.org

run code in 500+ PHP versions simultaneously
<?php function declareClassAndGetName() { $foo = new class { public function hello() { echo 'Hello', PHP_EOL; } }; return get_class(new $foo); } $className = declareClassAndGetName(); $foo = new $className; $foo->hello();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n7YdT
function name:  (null)
number of ops:  10
compiled vars:  !0 = $className, !1 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                                   'declareclassandgetname'
          1        DO_FCALL                                          0  $2      
          2        ASSIGN                                                       !0, $2
   15     3        FETCH_CLASS                                       0  $4      !0
          4        NEW                                                  $5      $4
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $5
   16     7        INIT_METHOD_CALL                                             !1, 'hello'
          8        DO_FCALL                                          0          
          9      > RETURN                                                       1

Function declareclassandgetname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n7YdT
function name:  declareClassAndGetName
number of ops:  10
compiled vars:  !0 = $foo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   DECLARE_ANON_CLASS                                   <unknown> 
          1        NEW                                                  $2      $1
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   10     4        FETCH_CLASS                                       0  $5      !0
          5        NEW                                                  $6      $5
          6        DO_FCALL                                          0          
          7        GET_CLASS                                            ~8      $6
          8      > RETURN                                                       ~8
   11     9*     > RETURN                                                       null

End of function declareclassandgetname

Class class@anonymous:
Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n7YdT
function name:  hello
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                         'Hello'
          1        ECHO                                                         '%0A'
    7     2      > RETURN                                                       null

End of function hello

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.22 ms | 3318 KiB | 14 Q