3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $prop; function setStr(string $x) { $this->prop = $x; } function setStrRef(string &$x) { $this->prop = &$x; } function setArray(array $arr) { $this->prop = $arr; } } $foo = new Foo(); $foo->setStr('abc'); var_dump($foo->prop); // "abc" $str = 'def'; // $str is a string $foo->setStrRef($str); var_dump($foo->prop); // "def" $arr = []; $foo->setArray($arr); var_dump($foo->prop); // [] var_dump($str); // [] - surprise! $str is now an array
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gqQur
function name:  (null)
number of ops:  30
compiled vars:  !0 = $foo, !1 = $str, !2 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   18     3        INIT_METHOD_CALL                                         !0, 'setStr'
          4        SEND_VAL_EX                                              'abc'
          5        DO_FCALL                                      0          
   19     6        INIT_FCALL                                               'var_dump'
          7        FETCH_OBJ_R                                      ~7      !0, 'prop'
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                                 
   21    10        ASSIGN                                                   !1, 'def'
   22    11        INIT_METHOD_CALL                                         !0, 'setStrRef'
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0          
   23    14        INIT_FCALL                                               'var_dump'
         15        FETCH_OBJ_R                                      ~11     !0, 'prop'
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                                 
   25    18        ASSIGN                                                   !2, <array>
   26    19        INIT_METHOD_CALL                                         !0, 'setArray'
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0          
   27    22        INIT_FCALL                                               'var_dump'
         23        FETCH_OBJ_R                                      ~15     !0, 'prop'
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                                 
   28    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

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

End of function setstr

Function setstrref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gqQur
function name:  setStrRef
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ_REF                                           'prop'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function setstrref

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

End of function setarray

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.36 ms | 1400 KiB | 15 Q