3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { var $foo = 1; } function update($obj) { $obj->foo = 3; } function replace($obj) { $a = new A; $a->foo = 3; $obj = $a; } function replaceByRef(&$obj) { $a = new A; $a->foo = 3; $obj = $a; } $a = new A; $b = new A; $c = new A; call_user_func_array("update", array(&$a)); call_user_func_array("replace", array(&$b)); call_user_func_array("replaceByRef", array(&$c)); echo $a->foo . "\n"; echo $b->foo . "\n"; echo $c->foo . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3g5cb
function name:  (null)
number of ops:  34
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $3      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
          3        NEW                                              $6      'A'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
          6        NEW                                              $9      'A'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $9
   24     9        INIT_FCALL                                               'update'
         10        INIT_ARRAY                                       ~12     !0
         11        SEND_ARRAY                                               ~12
         12        CHECK_UNDEF_ARGS                                         
         13        DO_FCALL                                      0          
   25    14        INIT_FCALL                                               'replace'
         15        INIT_ARRAY                                       ~14     !1
         16        SEND_ARRAY                                               ~14
         17        CHECK_UNDEF_ARGS                                         
         18        DO_FCALL                                      0          
   26    19        INIT_FCALL                                               'replacebyref'
         20        INIT_ARRAY                                       ~16     !2
         21        SEND_ARRAY                                               ~16
         22        CHECK_UNDEF_ARGS                                         
         23        DO_FCALL                                      0          
   28    24        FETCH_OBJ_R                                      ~18     !0, 'foo'
         25        CONCAT                                           ~19     ~18, '%0A'
         26        ECHO                                                     ~19
   29    27        FETCH_OBJ_R                                      ~20     !1, 'foo'
         28        CONCAT                                           ~21     ~20, '%0A'
         29        ECHO                                                     ~21
   30    30        FETCH_OBJ_R                                      ~22     !2, 'foo'
         31        CONCAT                                           ~23     ~22, '%0A'
         32        ECHO                                                     ~23
         33      > RETURN                                                   1

Function update:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3g5cb
function name:  update
number of ops:  4
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               !0, 'foo'
          2        OP_DATA                                                  3
    8     3      > RETURN                                                   null

End of function update

Function replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3g5cb
function name:  replace
number of ops:  8
compiled vars:  !0 = $obj, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        NEW                                              $2      'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   12     4        ASSIGN_OBJ                                               !1, 'foo'
          5        OP_DATA                                                  3
   13     6        ASSIGN                                                   !0, !1
   14     7      > RETURN                                                   null

End of function replace

Function replacebyref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3g5cb
function name:  replaceByRef
number of ops:  8
compiled vars:  !0 = $obj, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        NEW                                              $2      'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
   18     4        ASSIGN_OBJ                                               !1, 'foo'
          5        OP_DATA                                                  3
   19     6        ASSIGN                                                   !0, !1
   20     7      > RETURN                                                   null

End of function replacebyref

Class A: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.55 ms | 1407 KiB | 16 Q