3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ByRef { protected $argAge; protected $bothAge; public function assignJustArgByRef(&$age) { $this->argAge = $age; } public function assignArgAndExpressionByRef(&$age) { $this->bothAge =& $age; } public function getArgAge() { return $this->argAge; } public function getBothAge() { return $this->bothAge; } } $age = 0; $ByRef = new ByRef(); $ByRef->assignJustArgByRef($age); $age++; echo 'only param by ref: ' . $ByRef->getArgAge() . \PHP_EOL; $newAge = 0; $ByRef->assignArgAndExpressionByRef($newAge); $newAge++; echo 'param and expression by ref: ' . $ByRef->getBothAge() . \PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5qaNL
function name:  (null)
number of ops:  24
compiled vars:  !0 = $age, !1 = $ByRef, !2 = $newAge
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, 0
   27     1        NEW                                              $4      'ByRef'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   29     4        INIT_METHOD_CALL                                         !1, 'assignJustArgByRef'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   30     7        PRE_INC                                                  !0
   31     8        INIT_METHOD_CALL                                         !1, 'getArgAge'
          9        DO_FCALL                                      0  $9      
         10        CONCAT                                           ~10     'only+param+by+ref%3A+', $9
         11        CONCAT                                           ~11     ~10, '%0A'
         12        ECHO                                                     ~11
   34    13        ASSIGN                                                   !2, 0
   35    14        INIT_METHOD_CALL                                         !1, 'assignArgAndExpressionByRef'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
   36    17        PRE_INC                                                  !2
   37    18        INIT_METHOD_CALL                                         !1, 'getBothAge'
         19        DO_FCALL                                      0  $15     
         20        CONCAT                                           ~16     'param+and+expression+by+ref%3A+', $15
         21        CONCAT                                           ~17     ~16, '%0A'
         22        ECHO                                                     ~17
         23      > RETURN                                                   1

Class ByRef:
Function assignjustargbyref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5qaNL
function name:  assignJustArgByRef
number of ops:  4
compiled vars:  !0 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'argAge'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function assignjustargbyref

Function assignargandexpressionbyref:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5qaNL
function name:  assignArgAndExpressionByRef
number of ops:  4
compiled vars:  !0 = $age
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ASSIGN_OBJ_REF                                           'bothAge'
          2        OP_DATA                                                  !0
   14     3      > RETURN                                                   null

End of function assignargandexpressionbyref

Function getargage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5qaNL
function name:  getArgAge
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                      ~0      'argAge'
          1      > RETURN                                                   ~0
   18     2*     > RETURN                                                   null

End of function getargage

Function getbothage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5qaNL
function name:  getBothAge
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~0      'bothAge'
          1      > RETURN                                                   ~0
   22     2*     > RETURN                                                   null

End of function getbothage

End of class ByRef.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.63 ms | 1399 KiB | 13 Q