3v4l.org

run code in 500+ PHP versions simultaneously
<?php class C { function foo(&$a, $b) { $a = 'modified'; $b = 'modified'; } } class S { static function foo(&$a, $b) { $a = 'modified'; $b = 'modified'; } } $a = $b = 'orig'; $f = array(new C, 'foo'); $f($a, $b); assert($a === 'modified'); assert($b === 'orig'); $a = $b = 'orig'; $f = array('S', 'foo'); $f($a, $b); assert($a === 'modified'); assert($b === 'orig'); $a = $b = 'orig'; $f = 'S::foo'; $f($a, $b); assert($a === 'modified'); assert($b === 'orig'); $a = $b = 'orig'; $f = function(&$a, $b) { $a = 'modified'; $b = 'modified'; }; $f($a, $b); assert($a === 'modified'); assert($b === 'orig');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vbJRt
function name:  (null)
number of ops:  82
compiled vars:  !0 = $a, !1 = $b, !2 = $f
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                               ~3      !1, 'orig'
          1        ASSIGN                                                       !0, ~3
   18     2        NEW                                                  $5      'C'
          3        DO_FCALL                                          0          
          4        INIT_ARRAY                                           ~7      $5
          5        ADD_ARRAY_ELEMENT                                    ~7      'foo'
          6        ASSIGN                                                       !2, ~7
   19     7        INIT_DYNAMIC_CALL                                            !2
          8        SEND_VAR_EX                                                  !0
          9        SEND_VAR_EX                                                  !1
         10        DO_FCALL                                          0          
   20    11        ASSERT_CHECK                                                 
         12        INIT_FCALL                                                   'assert'
         13        IS_IDENTICAL                                         ~10     !0, 'modified'
         14        SEND_VAL                                                     ~10
         15        SEND_VAL                                                     'assert%28%24a+%3D%3D%3D+%27modified%27%29'
         16        DO_ICALL                                                     
   21    17        ASSERT_CHECK                                                 
         18        INIT_FCALL                                                   'assert'
         19        IS_IDENTICAL                                         ~12     !1, 'orig'
         20        SEND_VAL                                                     ~12
         21        SEND_VAL                                                     'assert%28%24b+%3D%3D%3D+%27orig%27%29'
         22        DO_ICALL                                                     
   23    23        ASSIGN                                               ~14     !1, 'orig'
         24        ASSIGN                                                       !0, ~14
   24    25        ASSIGN                                                       !2, <array>
   25    26        INIT_DYNAMIC_CALL                                            !2
         27        SEND_VAR_EX                                                  !0
         28        SEND_VAR_EX                                                  !1
         29        DO_FCALL                                          0          
   26    30        ASSERT_CHECK                                                 
         31        INIT_FCALL                                                   'assert'
         32        IS_IDENTICAL                                         ~18     !0, 'modified'
         33        SEND_VAL                                                     ~18
         34        SEND_VAL                                                     'assert%28%24a+%3D%3D%3D+%27modified%27%29'
         35        DO_ICALL                                                     
   27    36        ASSERT_CHECK                                                 
         37        INIT_FCALL                                                   'assert'
         38        IS_IDENTICAL                                         ~20     !1, 'orig'
         39        SEND_VAL                                                     ~20
         40        SEND_VAL                                                     'assert%28%24b+%3D%3D%3D+%27orig%27%29'
         41        DO_ICALL                                                     
   29    42        ASSIGN                                               ~22     !1, 'orig'
         43        ASSIGN                                                       !0, ~22
   30    44        ASSIGN                                                       !2, 'S%3A%3Afoo'
   31    45        INIT_DYNAMIC_CALL                                            !2
         46        SEND_VAR_EX                                                  !0
         47        SEND_VAR_EX                                                  !1
         48        DO_FCALL                                          0          
   32    49        ASSERT_CHECK                                                 
         50        INIT_FCALL                                                   'assert'
         51        IS_IDENTICAL                                         ~26     !0, 'modified'
         52        SEND_VAL                                                     ~26
         53        SEND_VAL                                                     'assert%28%24a+%3D%3D%3D+%27modified%27%29'
         54        DO_ICALL                                                     
   33    55        ASSERT_CHECK                                                 
         56        INIT_FCALL                                                   'assert'
         57        IS_IDENTICAL                                         ~28     !1, 'orig'
         58        SEND_VAL                                                     ~28
         59        SEND_VAL                                                     'assert%28%24b+%3D%3D%3D+%27orig%27%29'
         60        DO_ICALL                                                     
   35    61        ASSIGN                                               ~30     !1, 'orig'
         62        ASSIGN                                                       !0, ~30
   36    63        DECLARE_LAMBDA_FUNCTION                              ~32     [0]
         64        ASSIGN                                                       !2, ~32
   40    65        INIT_DYNAMIC_CALL                                            !2
         66        SEND_VAR_EX                                                  !0
         67        SEND_VAR_EX                                                  !1
         68        DO_FCALL                                          0          
   41    69        ASSERT_CHECK                                                 
         70        INIT_FCALL                                                   'assert'
         71        IS_IDENTICAL                                         ~35     !0, 'modified'
         72        SEND_VAL                                                     ~35
         73        SEND_VAL                                                     'assert%28%24a+%3D%3D%3D+%27modified%27%29'
         74        DO_ICALL                                                     
   42    75        ASSERT_CHECK                                                 
         76        INIT_FCALL                                                   'assert'
         77        IS_IDENTICAL                                         ~37     !1, 'orig'
         78        SEND_VAL                                                     ~37
         79        SEND_VAL                                                     'assert%28%24b+%3D%3D%3D+%27orig%27%29'
         80        DO_ICALL                                                     
         81      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vbJRt
function name:  {closure:/in/vbJRt:36}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   37     2        ASSIGN                                                       !0, 'modified'
   38     3        ASSIGN                                                       !1, 'modified'
   39     4      > RETURN                                                       null

End of Dynamic Function 0

Class C:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vbJRt
function name:  foo
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        ASSIGN                                                       !0, 'modified'
    6     3        ASSIGN                                                       !1, 'modified'
    7     4      > RETURN                                                       null

End of function foo

End of class C.

Class S:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vbJRt
function name:  foo
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   12     2        ASSIGN                                                       !0, 'modified'
   13     3        ASSIGN                                                       !1, 'modified'
   14     4      > RETURN                                                       null

End of function foo

End of class S.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.36 ms | 2093 KiB | 14 Q