3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a { function __toString() { static $i = 0; $a = ['', 'a']; $r = $a[$i]; $i++; return $r; } } $a = new a; var_dump('' == $a and 'a' == $a); var_dump('' === (string)$a and 'a' === (string)$a);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 18
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 9
filename:       /in/OuP0K
function name:  (null)
number of ops:  21
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'a'
   13     1        NEW                                              $1      'a'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   14     4        INIT_FCALL                                               'var_dump'
          5        IS_EQUAL                                         ~4      !0, ''
          6      > JMPZ_EX                                          ~4      ~4, ->9
          7    >   IS_EQUAL                                         ~5      !0, 'a'
          8        BOOL                                             ~4      ~5
          9    >   SEND_VAL                                                 ~4
         10        DO_ICALL                                                 
   15    11        INIT_FCALL                                               'var_dump'
         12        CAST                                          6  ~7      !0
         13        IS_IDENTICAL                                     ~8      ~7, ''
         14      > JMPZ_EX                                          ~8      ~8, ->18
         15    >   CAST                                          6  ~9      !0
         16        IS_IDENTICAL                                     ~10     ~9, 'a'
         17        BOOL                                             ~8      ~10
         18    >   SEND_VAL                                                 ~8
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Class a:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OuP0K
function name:  __toString
number of ops:  9
compiled vars:  !0 = $i, !1 = $a, !2 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
    7     1        ASSIGN                                                   !1, <array>
    8     2        FETCH_DIM_R                                      ~4      !1, !0
          3        ASSIGN                                                   !2, ~4
    9     4        PRE_INC                                                  !0
   10     5        VERIFY_RETURN_TYPE                                       !2
          6      > RETURN                                                   !2
   11     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function __tostring

End of class a.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.81 ms | 1396 KiB | 15 Q