3v4l.org

run code in 300+ PHP versions simultaneously
<?php function change_obj($object) { $object->foo = 'bar'; } function replace_obj(&$object) { $object = new stdClass(); $object->foo = 'bar'; } function replace_obj_fail($object) { $object = new stdClass(); $object->foo = 'bar'; } $a = new stdClass(); change_obj($a); var_dump($a); $b = new stdClass(); replace_obj($b); var_dump($b); $c = new stdClass(); replace_obj_fail($c); var_dump($c);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1q6Ll
function name:  (null)
number of ops:  28
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   16     3        INIT_FCALL                                               'change_obj'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0          
   17     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   19     9        NEW                                              $8      'stdClass'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $8
   20    12        INIT_FCALL                                               'replace_obj'
         13        SEND_REF                                                 !1
         14        DO_FCALL                                      0          
   21    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
   23    18        NEW                                              $13     'stdClass'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !2, $13
   24    21        INIT_FCALL                                               'replace_obj_fail'
         22        SEND_VAR                                                 !2
         23        DO_FCALL                                      0          
   25    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

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

End of function change_obj

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

End of function replace_obj

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

End of function replace_obj_fail

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.33 ms | 1403 KiB | 18 Q