3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Demo { } // An "autoload" handler creating an alias for the same class spl_autoload_register(function ($class) { echo "autoload $class\n"; class_alias('Demo', $class); }); // Create a Demo object using "A" // and pass that to function expecting "A" function success(A $test) { echo "Success ".get_class($test)."\n"; } echo "1\n"; success(new A()); // Create a Demo object using "B", // then create another Demo object using "C" // and pass that to function expecting "B" function also(B $test) { echo "Success ".get_class($test)."\n"; } echo "2\n"; new B(); echo "3\n"; also(new C()); // Create a Demo object using "X", // and pass that to function expecting "B" function fail(X $test) { echo "Success ".get_class($test)."\n"; } echo "4\n"; fail(new Y()); // Note that all of these names refer to the same class, // and all objects are of the same class
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NuX6K
function name:  (null)
number of ops:  27
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'spl_autoload_register'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNuX6K%3A6%240'
    9     2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   16     4        ECHO                                                     '1%0A'
   17     5        INIT_FCALL                                               'success'
          6        NEW                                              $2      'A'
          7        DO_FCALL                                      0          
          8        SEND_VAR                                                 $2
          9        DO_FCALL                                      0          
   25    10        ECHO                                                     '2%0A'
   26    11        NEW                                              $5      'B'
         12        DO_FCALL                                      0          
         13        FREE                                                     $5
   27    14        ECHO                                                     '3%0A'
   28    15        INIT_FCALL                                               'also'
         16        NEW                                              $7      'C'
         17        DO_FCALL                                      0          
         18        SEND_VAR                                                 $7
         19        DO_FCALL                                      0          
   35    20        ECHO                                                     '4%0A'
   36    21        INIT_FCALL                                               'fail'
         22        NEW                                              $10     'Y'
         23        DO_FCALL                                      0          
         24        SEND_VAR                                                 $10
         25        DO_FCALL                                      0          
   39    26      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FNuX6K%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NuX6K
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ROPE_INIT                                     3  ~2      'autoload+'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%0A'
          4        ECHO                                                     ~1
    8     5        INIT_FCALL                                               'class_alias'
          6        SEND_VAL                                                 'Demo'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
    9     9      > RETURN                                                   null

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

Function success:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NuX6K
function name:  success
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        GET_CLASS                                        ~1      !0
          2        CONCAT                                           ~2      'Success+', ~1
          3        CONCAT                                           ~3      ~2, '%0A'
          4        ECHO                                                     ~3
   15     5      > RETURN                                                   null

End of function success

Function also:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NuX6K
function name:  also
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        GET_CLASS                                        ~1      !0
          2        CONCAT                                           ~2      'Success+', ~1
          3        CONCAT                                           ~3      ~2, '%0A'
          4        ECHO                                                     ~3
   24     5      > RETURN                                                   null

End of function also

Function fail:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NuX6K
function name:  fail
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        GET_CLASS                                        ~1      !0
          2        CONCAT                                           ~2      'Success+', ~1
          3        CONCAT                                           ~3      ~2, '%0A'
          4        ECHO                                                     ~3
   34     5      > RETURN                                                   null

End of function fail

Class Demo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.84 ms | 1403 KiB | 20 Q