3v4l.org

run code in 300+ PHP versions simultaneously
<?php $originalObj = new A; class A { var $foo = 'default value'; } // Important note: If you remove the &, the bug disappears. function changeFooWithUnusedReference( &$unusedReferenceToFoo, $newValue ) { global $originalObj; $newObj = clone $originalObj; echo $originalObj->foo . "\n"; echo $newObj->foo . "\n"; $newObj->foo = $newValue; echo $originalObj->foo . "\n"; echo $newObj->foo . "\n"; } changeFooWithUnusedReference( $originalObj->foo, 'Some other value' );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0psBF
function name:  (null)
number of ops:  9
compiled vars:  !0 = $originalObj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $1      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   19     3        INIT_FCALL                                               'changefoowithunusedreference'
          4        FETCH_OBJ_W                                      $4      !0, 'foo'
          5        SEND_REF                                                 $4
          6        SEND_VAL                                                 'Some+other+value'
          7        DO_FCALL                                      0          
          8      > RETURN                                                   1

Function changefoowithunusedreference:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0psBF
function name:  changeFooWithUnusedReference
number of ops:  20
compiled vars:  !0 = $unusedReferenceToFoo, !1 = $newValue, !2 = $originalObj, !3 = $newObj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        BIND_GLOBAL                                              !2, 'originalObj'
    9     3        CLONE                                            ~4      !2
          4        ASSIGN                                                   !3, ~4
   11     5        FETCH_OBJ_R                                      ~6      !2, 'foo'
          6        CONCAT                                           ~7      ~6, '%0A'
          7        ECHO                                                     ~7
   12     8        FETCH_OBJ_R                                      ~8      !3, 'foo'
          9        CONCAT                                           ~9      ~8, '%0A'
         10        ECHO                                                     ~9
   14    11        ASSIGN_OBJ                                               !3, 'foo'
         12        OP_DATA                                                  !1
   16    13        FETCH_OBJ_R                                      ~11     !2, 'foo'
         14        CONCAT                                           ~12     ~11, '%0A'
         15        ECHO                                                     ~12
   17    16        FETCH_OBJ_R                                      ~13     !3, 'foo'
         17        CONCAT                                           ~14     ~13, '%0A'
         18        ECHO                                                     ~14
   18    19      > RETURN                                                   null

End of function changefoowithunusedreference

Class A: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.29 ms | 1399 KiB | 14 Q