3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SubObject { static $instances = 0; public $instance; public function __construct() { $this->instance = ++self::$instances; } public function __clone() { $this->instance = ++self::$instances; } } class MyCloneable { public $object1; public $object2; function __clone() { // Force a copy of this->object, otherwise // it will point to same object. $this->object1 = clone $this->object1; } } $obj = new MyCloneable(); $obj->object1 = new SubObject(); $obj->object2 = new SubObject(); $obj2 = clone $obj; print("Original Object:\n"); print_r($obj); print("Cloned Object:\n"); print_r($obj2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QoZSU
function name:  (null)
number of ops:  22
compiled vars:  !0 = $obj, !1 = $obj2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $2      'MyCloneable'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   31     3        NEW                                              $6      'SubObject'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'object1'
          6        OP_DATA                                                  $6
   32     7        NEW                                              $9      'SubObject'
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !0, 'object2'
         10        OP_DATA                                                  $9
   34    11        CLONE                                            ~11     !0
         12        ASSIGN                                                   !1, ~11
   37    13        ECHO                                                     'Original+Object%3A%0A'
   38    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
   40    17        ECHO                                                     'Cloned+Object%3A%0A'
   41    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Class SubObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QoZSU
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   PRE_INC_STATIC_PROP                              ~1      'instances'
          1        ASSIGN_OBJ                                               'instance'
          2        OP_DATA                                                  ~1
    9     3      > RETURN                                                   null

End of function __construct

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QoZSU
function name:  __clone
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   PRE_INC_STATIC_PROP                              ~1      'instances'
          1        ASSIGN_OBJ                                               'instance'
          2        OP_DATA                                                  ~1
   13     3      > RETURN                                                   null

End of function __clone

End of class SubObject.

Class MyCloneable:
Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QoZSU
function name:  __clone
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~1      'object1'
          1        CLONE                                            ~2      ~1
          2        ASSIGN_OBJ                                               'object1'
          3        OP_DATA                                                  ~2
   26     4      > RETURN                                                   null

End of function __clone

End of class MyCloneable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.34 ms | 1400 KiB | 15 Q