3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { protected $arr; public function __construct() { $this->arr = array(); } public function getArr() { return $this->arr; } public function append($arr) { $this->$arr[] = $arr; } public function merge($arr) { $this->arr = array_merge($this->arr, $arr); } } $arr = array('a','b'); $obj = new MyClass(); $obj->append($arr);//使用append无法修改类属性 var_dump($obj->getArr()); //output : //array(0){} $obj->merge($arr);//使用merge可以 var_dump($obj->getArr()); //output: //array(2){'a','b'}
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Mq98
function name:  (null)
number of ops:  21
compiled vars:  !0 = $arr, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, <array>
   26     1        NEW                                              $3      'MyClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   28     4        INIT_METHOD_CALL                                         !1, 'append'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   29     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !1, 'getArr'
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR                                                 $7
         11        DO_ICALL                                                 
   33    12        INIT_METHOD_CALL                                         !1, 'merge'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   34    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !1, 'getArr'
         17        DO_FCALL                                      0  $10     
         18        SEND_VAR                                                 $10
         19        DO_ICALL                                                 
   36    20      > RETURN                                                   1

Class MyClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Mq98
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                               'arr'
          1        OP_DATA                                                  <array>
    8     2      > RETURN                                                   null

End of function __construct

Function getarr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Mq98
function name:  getArr
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'arr'
          1      > RETURN                                                   ~0
   12     2*     > RETURN                                                   null

End of function getarr

Function append:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Mq98
function name:  append
number of ops:  5
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        FETCH_OBJ_W                                      $1      !0
          2        ASSIGN_DIM                                               $1
          3        OP_DATA                                                  !0
   16     4      > RETURN                                                   null

End of function append

Function merge:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Mq98
function name:  merge
number of ops:  9
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'array_merge'
          2        FETCH_OBJ_R                                      ~2      'arr'
          3        SEND_VAL                                                 ~2
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN_OBJ                                               'arr'
          7        OP_DATA                                                  $3
   20     8      > RETURN                                                   null

End of function merge

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.77 ms | 1400 KiB | 17 Q