3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $_b; private static $_instance; public function __construct($b) { $this->_b = $b; } public function __toString() { return $this->_b . PHP_EOL; } public static function getInstance($b = NULL) { if( ! isset(self::$_instance)){ self::$_instance = new self($b); } return self::$_instance; } } $a = A::getInstance("Test 1"); $b = A::getInstance("Test 2"); echo $a; echo $b;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uhC1i
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'a'
   27     1        INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
          2        SEND_VAL_EX                                              'Test+1'
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   28     5        INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
          6        SEND_VAL_EX                                              'Test+2'
          7        DO_FCALL                                      0  $4      
          8        ASSIGN                                                   !1, $4
   30     9        ECHO                                                     !0
   31    10        ECHO                                                     !1
         11      > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uhC1i
function name:  __construct
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               '_b'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uhC1i
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      '_b'
          1        CONCAT                                           ~1      ~0, '%0A'
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   15     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __tostring

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/uhC1i
function name:  getInstance
number of ops:  12
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV_INIT                                        !0      null
   19     1        ISSET_ISEMPTY_STATIC_PROP                        ~1      '_instance'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->9
   20     4    >   NEW                          self                $4      
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN_STATIC_PROP                                       '_instance'
          8        OP_DATA                                                  $4
   23     9    >   FETCH_STATIC_PROP_R          unknown             ~6      '_instance'
         10      > RETURN                                                   ~6
   24    11*     > RETURN                                                   null

End of function getinstance

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.67 ms | 1399 KiB | 13 Q