3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Form { private $_formData; function bind1(&$row) { $this->_formData = $row; // this change member outside $row['full_name'] = $row['first_name'] . ' ' . $row['last_name']; } function bind2(&$row) { $this->_formData = $row; // this will not change memeber $this->_formData['full_name'] = $this->_formData['first_name'] . ' ' . $this->_formData['last_name']; } } $member = array('fullName' => null, 'first_name'=>'Fn', 'last_name' => 'Ln'); $form = new Form(); $form->bind1($member); var_dump($member['fullName']); // output: 'FnLn' $form->bind2($member); var_dump($member['fullName']); // output: ''
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VTglK
function name:  (null)
number of ops:  19
compiled vars:  !0 = $member, !1 = $form
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, <array>
   26     1        NEW                                              $3      'Form'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   28     4        INIT_METHOD_CALL                                         !1, 'bind1'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   29     7        INIT_FCALL                                               'var_dump'
          8        FETCH_DIM_R                                      ~7      !0, 'fullName'
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                                 
   32    11        INIT_METHOD_CALL                                         !1, 'bind2'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
   33    14        INIT_FCALL                                               'var_dump'
         15        FETCH_DIM_R                                      ~10     !0, 'fullName'
         16        SEND_VAL                                                 ~10
         17        DO_ICALL                                                 
   34    18      > RETURN                                                   1

Class Form:
Function bind1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VTglK
function name:  bind1
number of ops:  10
compiled vars:  !0 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               '_formData'
          2        OP_DATA                                                  !0
   10     3        FETCH_DIM_R                                      ~3      !0, 'first_name'
   11     4        CONCAT                                           ~4      ~3, '+'
   12     5        FETCH_DIM_R                                      ~5      !0, 'last_name'
          6        CONCAT                                           ~6      ~4, ~5
    9     7        ASSIGN_DIM                                               !0, 'full_name'
   12     8        OP_DATA                                                  ~6
   13     9      > RETURN                                                   null

End of function bind1

Function bind2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VTglK
function name:  bind2
number of ops:  13
compiled vars:  !0 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        ASSIGN_OBJ                                               '_formData'
          2        OP_DATA                                                  !0
   19     3        FETCH_OBJ_R                                      ~4      '_formData'
          4        FETCH_DIM_R                                      ~5      ~4, 'first_name'
   20     5        CONCAT                                           ~6      ~5, '+'
   21     6        FETCH_OBJ_R                                      ~7      '_formData'
          7        FETCH_DIM_R                                      ~8      ~7, 'last_name'
          8        CONCAT                                           ~9      ~6, ~8
   18     9        FETCH_OBJ_W                                      $2      '_formData'
         10        ASSIGN_DIM                                               $2, 'full_name'
   21    11        OP_DATA                                                  ~9
   22    12      > RETURN                                                   null

End of function bind2

End of class Form.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.13 ms | 1392 KiB | 15 Q