3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SubObject { static $instances = 0; public $instance; public function __construct() { $this->instance = ++self::$instances; } } class MyCloneable { public $object1; public $object2; function __clone() { // forza la copia di $this->object1, che altrimenti // punterebbe alla stessa istanza. $this->object1 = clone $this->object1; } /*public function __invoke($object1,$object2) { $this->oject1=$object1; $this->oject2=$object2; } */ } $obj = new MyCloneable(); $obj3 = clone $obj; $obj->object1 = new SubObject(); $obj->object2 = new SubObject(); $obj3 = clone $obj; $obj2=new $obj; $obj2->object1 = new SubObject(); $obj2->object2 = new SubObject(); print("Oggetto originale:\n"); print_r($obj); print("Oggetto originale:\n"); print_r($obj2); print("Oggetto clonato:\n"); print_r($obj3); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F4ovb
function name:  (null)
number of ops:  40
compiled vars:  !0 = $obj, !1 = $obj3, !2 = $obj2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $3      'MyCloneable'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   33     3        CLONE                                            ~6      !0
          4        ASSIGN                                                   !1, ~6
   34     5        NEW                                              $9      'SubObject'
          6        DO_FCALL                                      0          
          7        ASSIGN_OBJ                                               !0, 'object1'
          8        OP_DATA                                                  $9
   35     9        NEW                                              $12     'SubObject'
         10        DO_FCALL                                      0          
         11        ASSIGN_OBJ                                               !0, 'object2'
         12        OP_DATA                                                  $12
   37    13        CLONE                                            ~14     !0
         14        ASSIGN                                                   !1, ~14
   39    15        FETCH_CLASS                                   0  $16     !0
         16        NEW                                              $17     $16
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !2, $17
   40    19        NEW                                              $21     'SubObject'
         20        DO_FCALL                                      0          
         21        ASSIGN_OBJ                                               !2, 'object1'
         22        OP_DATA                                                  $21
   41    23        NEW                                              $24     'SubObject'
         24        DO_FCALL                                      0          
         25        ASSIGN_OBJ                                               !2, 'object2'
         26        OP_DATA                                                  $24
   43    27        ECHO                                                     'Oggetto+originale%3A%0A'
   44    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
   46    31        ECHO                                                     'Oggetto+originale%3A%0A'
   47    32        INIT_FCALL                                               'print_r'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                                 
   48    35        ECHO                                                     'Oggetto+clonato%3A%0A'
   49    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                                 
   50    39      > RETURN                                                   1

Class SubObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F4ovb
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

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/F4ovb
function name:  __clone
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~1      'object1'
          1        CLONE                                            ~2      ~1
          2        ASSIGN_OBJ                                               'object1'
          3        OP_DATA                                                  ~2
   22     4      > RETURN                                                   null

End of function __clone

End of class MyCloneable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.93 ms | 1400 KiB | 15 Q