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('' === (string)$a and 'a' === (string)$a);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/EjVof
function name:  (null)
number of ops:  14
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        CAST                                          6  ~4      !0
          6        IS_IDENTICAL                                     ~5      ~4, ''
          7      > JMPZ_EX                                          ~5      ~5, ->11
          8    >   CAST                                          6  ~6      !0
          9        IS_IDENTICAL                                     ~7      ~6, 'a'
         10        BOOL                                             ~5      ~7
         11    >   SEND_VAL                                                 ~5
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class a:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EjVof
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.26 ms | 1395 KiB | 15 Q