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(); $obj->object1 = new SubObject(); $obj->object2 = new SubObject(); $obj2=new $obj; $obj2->object1 = new SubObject(); $obj2->object2 = new SubObject(); $obj3 = clone $obj; 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/Iivoq
function name:  (null)
number of ops:  38
compiled vars:  !0 = $obj, !1 = $obj2, !2 = $obj3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $3      'MyCloneable'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   34     3        NEW                                              $7      'SubObject'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               !0, 'object1'
          6        OP_DATA                                                  $7
   35     7        NEW                                              $10     'SubObject'
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !0, 'object2'
         10        OP_DATA                                                  $10
   39    11        FETCH_CLASS                                   0  $12     !0
         12        NEW                                              $13     $12
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $13
   40    15        NEW                                              $17     'SubObject'
         16        DO_FCALL                                      0          
         17        ASSIGN_OBJ                                               !1, 'object1'
         18        OP_DATA                                                  $17
   41    19        NEW                                              $20     'SubObject'
         20        DO_FCALL                                      0          
         21        ASSIGN_OBJ                                               !1, 'object2'
         22        OP_DATA                                                  $20
   42    23        CLONE                                            ~22     !0
         24        ASSIGN                                                   !2, ~22
   43    25        ECHO                                                     'Oggetto+originale%3A%0A'
   44    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
   46    29        ECHO                                                     'Oggetto+originale%3A%0A'
   47    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
   48    33        ECHO                                                     'Oggetto+clonato%3A%0A'
   49    34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
   50    37      > RETURN                                                   1

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

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Iivoq
function name:  __invoke
number of ops:  7
compiled vars:  !0 = $object1, !1 = $object2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   27     2        ASSIGN_OBJ                                               'oject1'
          3        OP_DATA                                                  !0
   28     4        ASSIGN_OBJ                                               'oject2'
          5        OP_DATA                                                  !1
   29     6      > RETURN                                                   null

End of function __invoke

End of class MyCloneable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.49 ms | 1400 KiB | 15 Q