3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new stdClass; $b = $a; var_dump(is_ref($a, $b)); function is_ref(&$a, &$b) { if ($a !== $b) return false; // create a unique different value $differentValue = ($a === true) ? false : true; // We need a copy of $a, to keep safe. Note that if $a is a "referenced" value, $copy will be too. $copy = $a; // Change $a and check if $b changed too, finally restore $a using $copy. $a = $differentValue; $same = $a === $b; $a = $copy; return $same; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/umJ7m
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
    4     3        ASSIGN                                                   !1, !0
    6     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL_BY_NAME                                       'is_ref'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   25    11      > RETURN                                                   1

Function is_ref:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/umJ7m
function name:  is_ref
number of ops:  18
compiled vars:  !0 = $a, !1 = $b, !2 = $differentValue, !3 = $copy, !4 = $same
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        IS_NOT_IDENTICAL                                         !0, !1
          3      > JMPZ                                                     ~5, ->5
   11     4    > > RETURN                                                   <false>
   14     5    >   TYPE_CHECK                                    8          !0
          6      > JMPZ                                                     ~6, ->9
          7    >   QM_ASSIGN                                        ~7      <false>
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~7      <true>
         10    >   ASSIGN                                                   !2, ~7
   17    11        ASSIGN                                                   !3, !0
   20    12        ASSIGN                                                   !0, !2
   21    13        IS_IDENTICAL                                     ~11     !0, !1
         14        ASSIGN                                                   !4, ~11
   22    15        ASSIGN                                                   !0, !3
   24    16      > RETURN                                                   !4
   25    17*     > RETURN                                                   null

End of function is_ref

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.12 ms | 1388 KiB | 15 Q