3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { protected $i = 0; public function __toString() { $this->i++; return "$this->i"; } } $a = new A; $b = [100, $a]; $c = [100, (string) $a]; $d = [100, $a]; var_dump( array_intersect($b, $b), array_intersect($c, $c), array_intersect($d, $d) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KrIW6
function name:  (null)
number of ops:  32
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'a'
   11     1        NEW                                              $4      'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
   13     4        INIT_ARRAY                                       ~7      100
          5        ADD_ARRAY_ELEMENT                                ~7      !0
          6        ASSIGN                                                   !1, ~7
   14     7        INIT_ARRAY                                       ~9      100
          8        CAST                                          6  ~10     !0
          9        ADD_ARRAY_ELEMENT                                ~9      ~10
         10        ASSIGN                                                   !2, ~9
   15    11        INIT_ARRAY                                       ~12     100
         12        ADD_ARRAY_ELEMENT                                ~12     !0
         13        ASSIGN                                                   !3, ~12
   17    14        INIT_FCALL                                               'var_dump'
   18    15        INIT_FCALL                                               'array_intersect'
         16        SEND_VAR                                                 !1
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $14     
         19        SEND_VAR                                                 $14
   19    20        INIT_FCALL                                               'array_intersect'
         21        SEND_VAR                                                 !2
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $15     
         24        SEND_VAR                                                 $15
   20    25        INIT_FCALL                                               'array_intersect'
         26        SEND_VAR                                                 !3
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                         $16     
         29        SEND_VAR                                                 $16
   17    30        DO_ICALL                                                 
   21    31      > RETURN                                                   1

Class A:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KrIW6
function name:  __toString
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   PRE_INC_OBJ                                              'i'
    7     1        FETCH_OBJ_R                                      ~1      'i'
          2        CAST                                          6  ~2      ~1
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
    8     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function __tostring

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
245.45 ms | 1002 KiB | 15 Q