3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { private static $instance = null; private $my_value = 'Foo'; public function __construct() { } public static function my_function() { if ( !isset(self::$instance) ) self::$instance = new self; if( isset( $this ) ) { $target = $this; // I know its an invalid declaration } else { $target = self::$instance; // I know its an invalid declaration } return $target->my_value; // Invalid statement } } $my_object = new MyClass(); echo $my_object->my_function()."\n"; echo MyClass::my_function();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TEQtR
function name:  (null)
number of ops:  11
compiled vars:  !0 = $my_object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'MyClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   25     3        INIT_METHOD_CALL                                         !0, 'my_function'
          4        DO_FCALL                                      0  $4      
          5        CONCAT                                           ~5      $4, '%0A'
          6        ECHO                                                     ~5
   26     7        INIT_STATIC_METHOD_CALL                                  'MyClass', 'my_function'
          8        DO_FCALL                                      0  $6      
          9        ECHO                                                     $6
         10      > RETURN                                                   1

Class MyClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TEQtR
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   null

End of function __construct

Function my_function:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/TEQtR
function name:  my_function
number of ops:  17
compiled vars:  !0 = $target
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ISSET_ISEMPTY_STATIC_PROP                        ~1      'instance'
          1        BOOL_NOT                                         ~2      ~1
          2      > JMPZ                                                     ~2, ->7
   13     3    >   NEW                          self                $4      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $4
   15     7    >   ISSET_ISEMPTY_THIS                               ~6      
          8      > JMPZ                                                     ~6, ->12
   16     9    >   FETCH_THIS                                       ~7      
         10        ASSIGN                                                   !0, ~7
         11      > JMP                                                      ->14
   18    12    >   FETCH_STATIC_PROP_R          unknown             ~9      'instance'
         13        ASSIGN                                                   !0, ~9
   20    14    >   FETCH_OBJ_R                                      ~11     !0, 'my_value'
         15      > RETURN                                                   ~11
   21    16*     > RETURN                                                   null

End of function my_function

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.85 ms | 1386 KiB | 13 Q