3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class Foo { private $id; public function __construct() { $this->id = uniqid('', false); } public function setId($id) { $this->id = $id; } } $foo1 = new Foo(); $foo2 = new Foo(); $a = new ArrayObject([$foo1, $foo2]); $b = new ArrayObject(); foreach ($a as $i => $foo) { $b->offsetSet($i, $foo); } echo 'Initial state of Copy:' . PHP_EOL;; var_export($b); echo PHP_EOL . '-----------------------' . PHP_EOL; //form submission $foo1->setId('Hello World'); echo 'Form Submitted ID Changed in Copy:' . PHP_EOL;; var_export($b); echo PHP_EOL . '-----------------------' . PHP_EOL; echo 'Source has foo2 entity removed:' . PHP_EOL;; $a->offsetUnset(1); //remove entity var_export($a); echo PHP_EOL . '-----------------------' . PHP_EOL; echo 'Copy still contains both entities:' . PHP_EOL;; var_export($b);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/oLZqO
function name:  (null)
number of ops:  50
compiled vars:  !0 = $foo1, !1 = $foo2, !2 = $a, !3 = $b, !4 = $foo, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $6      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   19     3        NEW                                              $9      'Foo'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $9
   21     6        NEW                                              $12     'ArrayObject'
          7        INIT_ARRAY                                       ~13     !0
          8        ADD_ARRAY_ELEMENT                                ~13     !1
          9        SEND_VAL_EX                                              ~13
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $12
   23    12        NEW                                              $16     'ArrayObject'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $16
   24    15      > FE_RESET_R                                       $19     !2, ->23
         16    > > FE_FETCH_R                                       ~20     $19, !4, ->23
         17    >   ASSIGN                                                   !5, ~20
   25    18        INIT_METHOD_CALL                                         !3, 'offsetSet'
         19        SEND_VAR_EX                                              !5
         20        SEND_VAR_EX                                              !4
         21        DO_FCALL                                      0          
   24    22      > JMP                                                      ->16
         23    >   FE_FREE                                                  $19
   27    24        ECHO                                                     'Initial+state+of+Copy%3A%0A'
   28    25        INIT_FCALL                                               'var_export'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                                 
   29    28        ECHO                                                     '%0A-----------------------%0A'
   31    29        INIT_METHOD_CALL                                         !0, 'setId'
         30        SEND_VAL_EX                                              'Hello+World'
         31        DO_FCALL                                      0          
   32    32        ECHO                                                     'Form+Submitted+ID+Changed+in+Copy%3A%0A'
   33    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                                 
   34    36        ECHO                                                     '%0A-----------------------%0A'
   36    37        ECHO                                                     'Source+has+foo2+entity+removed%3A%0A'
   37    38        INIT_METHOD_CALL                                         !2, 'offsetUnset'
         39        SEND_VAL_EX                                              1
         40        DO_FCALL                                      0          
   38    41        INIT_FCALL                                               'var_export'
         42        SEND_VAR                                                 !2
         43        DO_ICALL                                                 
   39    44        ECHO                                                     '%0A-----------------------%0A'
   40    45        ECHO                                                     'Copy+still+contains+both+entities%3A%0A'
   41    46        INIT_FCALL                                               'var_export'
         47        SEND_VAR                                                 !3
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oLZqO
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'uniqid'
          1        SEND_VAL                                                 ''
          2        SEND_VAL                                                 <false>
          3        DO_ICALL                                         $1      
          4        ASSIGN_OBJ                                               'id'
          5        OP_DATA                                                  $1
   10     6      > RETURN                                                   null

End of function __construct

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

End of function setid

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.27 ms | 1008 KiB | 15 Q