3v4l.org

run code in 500+ PHP versions simultaneously
<?php class a{ public $n; public function __construct($n) { $this->n=$n; $this->N=&$this->n; } } class b{ public $n; public function __construct($n) { $this->n=$n; } } class c{ public function t($b){ $cb= clone $b; $cb->n='clone'; var_dump($cb->n,$b->n); } } $c=new c(); $a=new a('new'); $b=new b('new'); $n=&$b->n; //Class A specified reference when constructing, clone and modify the properties of the original object has no effect $c->t($a); //Class B specified external references, clone modify properties directly affect the original object properties $c->t($b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NRTJZ
function name:  (null)
number of ops:  20
compiled vars:  !0 = $c, !1 = $a, !2 = $b, !3 = $n
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   NEW                                                  $4      'c'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $4
   27     3        NEW                                                  $7      'a'
          4        SEND_VAL_EX                                                  'new'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $7
   28     7        NEW                                                  $10     'b'
          8        SEND_VAL_EX                                                  'new'
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !2, $10
   29    11        FETCH_OBJ_W                                          $13     !2, 'n'
         12        ASSIGN_REF                                                   !3, $13
   31    13        INIT_METHOD_CALL                                             !0, 't'
         14        SEND_VAR_EX                                                  !1
         15        DO_FCALL                                          0          
   33    16        INIT_METHOD_CALL                                             !0, 't'
         17        SEND_VAR_EX                                                  !2
         18        DO_FCALL                                          0          
         19      > RETURN                                                       1

Class a:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NRTJZ
function name:  __construct
number of ops:  8
compiled vars:  !0 = $n
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    7     1        ASSIGN_OBJ                                                   'n'
          2        OP_DATA                                                      !0
    8     3        FETCH_OBJ_W                                          $3      'n'
          4        MAKE_REF                                             $4      $3
          5        ASSIGN_OBJ_REF                                               'N'
          6        OP_DATA                                                      $4
    9     7      > RETURN                                                       null

End of function __construct

End of class a.

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

End of function __construct

End of class b.

Class c:
Function t:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NRTJZ
function name:  t
number of ops:  12
compiled vars:  !0 = $b, !1 = $cb
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV                                                 !0      
   20     1        CLONE                                                ~2      !0
          2        ASSIGN                                                       !1, ~2
   21     3        ASSIGN_OBJ                                                   !1, 'n'
          4        OP_DATA                                                      'clone'
   22     5        INIT_FCALL                                                   'var_dump'
          6        FETCH_OBJ_R                                          ~5      !1, 'n'
          7        SEND_VAL                                                     ~5
          8        FETCH_OBJ_R                                          ~6      !0, 'n'
          9        SEND_VAL                                                     ~6
         10        DO_ICALL                                                     
   23    11      > RETURN                                                       null

End of function t

End of class c.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
123.57 ms | 482 KiB | 8 Q