3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(0); if (PHP_VERSION_ID >= 80100) { eval(<<<PHP enum A: string { case A = 'A'; case B = 'B'; } enum B: string { case A = 'A'; case B = 'B'; } PHP); } class Str { public function __toString(): string { return 'A'; } } function vd(string $expr, bool $onlyTrue = false): void { $val = eval('return ' .$expr . ';'); if ($onlyTrue && $val !== true) { return; } echo $expr . ': '; var_dump($val); } $comparisons = [ '"A"', '1', '5', 'B::A', '(object) []', '[]', 'true', 'false', 'null', '(new Str())', ]; if (PHP_VERSION_ID >= 80100) { foreach ($comparisons as $comp) { vd("A::A == {$comp}"); vd("A::A != {$comp}"); vd("{$comp} == A::A"); vd("{$comp} != A::A"); vd("in_array(A::A, [{$comp}])"); vd("in_array({$comp}, [A::A])"); echo "\n"; } } else { $comparisons = array_diff($comparisons, ['B::A']); } foreach ($comparisons as $c1) { foreach ($comparisons as $c2) { if ($c1 === $c2) { continue; } vd("{$c1} == {$c2}", true); vd("in_array({$c1}, [{$c2}])", true); } echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 46
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 44
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 44
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 77) Position 1 = 52, Position 2 = 78
Branch analysis from position: 52
2 jumps found. (Code = 78) Position 1 = 53, Position 2 = 78
Branch analysis from position: 53
2 jumps found. (Code = 77) Position 1 = 54, Position 2 = 75
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 75
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 58
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 75
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
Branch analysis from position: 44
Branch analysis from position: 46
2 jumps found. (Code = 77) Position 1 = 52, Position 2 = 78
Branch analysis from position: 52
Branch analysis from position: 78
Branch analysis from position: 5
filename:       /in/Huc7t
function name:  (null)
number of ops:  80
compiled vars:  !0 = $comparisons, !1 = $comp, !2 = $c1, !3 = $c2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
    5     3      > JMPZ                                                     <true>, ->5
    7     4    >   INCLUDE_OR_EVAL                                          '++++enum+A%3A+string%0A++++%7B%0A++++++++case+A+%3D+%27A%27%3B%0A++++++++case+B+%3D+%27B%27%3B%0A++++%7D%0A%0A++++enum+B%3A+string%0A++++%7B%0A++++++++case+A+%3D+%27A%27%3B%0A++++++++case+B+%3D+%27B%27%3B%0A++++%7D', EVAL
   21     5    >   DECLARE_CLASS                                            'str'
   41     6        ASSIGN                                                   !0, <array>
   54     7      > JMPZ                                                     <true>, ->46
   55     8    > > FE_RESET_R                                       $7      !0, ->44
          9    > > FE_FETCH_R                                               $7, !1, ->44
   56    10    >   INIT_FCALL                                               'vd'
         11        NOP                                                      
         12        FAST_CONCAT                                      ~8      'A%3A%3AA+%3D%3D+', !1
         13        SEND_VAL                                                 ~8
         14        DO_FCALL                                      0          
   57    15        INIT_FCALL                                               'vd'
         16        NOP                                                      
         17        FAST_CONCAT                                      ~10     'A%3A%3AA+%21%3D+', !1
         18        SEND_VAL                                                 ~10
         19        DO_FCALL                                      0          
   58    20        INIT_FCALL                                               'vd'
         21        NOP                                                      
         22        FAST_CONCAT                                      ~12     !1, '+%3D%3D+A%3A%3AA'
         23        SEND_VAL                                                 ~12
         24        DO_FCALL                                      0          
   59    25        INIT_FCALL                                               'vd'
         26        NOP                                                      
         27        FAST_CONCAT                                      ~14     !1, '+%21%3D+A%3A%3AA'
         28        SEND_VAL                                                 ~14
         29        DO_FCALL                                      0          
   60    30        INIT_FCALL                                               'vd'
         31        ROPE_INIT                                     3  ~17     'in_array%28A%3A%3AA%2C+%5B'
         32        ROPE_ADD                                      1  ~17     ~17, !1
         33        ROPE_END                                      2  ~16     ~17, '%5D%29'
         34        SEND_VAL                                                 ~16
         35        DO_FCALL                                      0          
   61    36        INIT_FCALL                                               'vd'
         37        ROPE_INIT                                     3  ~21     'in_array%28'
         38        ROPE_ADD                                      1  ~21     ~21, !1
         39        ROPE_END                                      2  ~20     ~21, '%2C+%5BA%3A%3AA%5D%29'
         40        SEND_VAL                                                 ~20
         41        DO_FCALL                                      0          
   62    42        ECHO                                                     '%0A'
   55    43      > JMP                                                      ->9
         44    >   FE_FREE                                                  $7
   54    45      > JMP                                                      ->51
   65    46    >   INIT_FCALL                                               'array_diff'
         47        SEND_VAR                                                 !0
         48        SEND_VAL                                                 <array>
         49        DO_ICALL                                         $24     
         50        ASSIGN                                                   !0, $24
   68    51    > > FE_RESET_R                                       $26     !0, ->78
         52    > > FE_FETCH_R                                               $26, !2, ->78
   69    53    > > FE_RESET_R                                       $27     !0, ->75
         54    > > FE_FETCH_R                                               $27, !3, ->75
   70    55    >   IS_IDENTICAL                                             !2, !3
         56      > JMPZ                                                     ~28, ->58
   71    57    > > JMP                                                      ->54
   74    58    >   INIT_FCALL                                               'vd'
         59        ROPE_INIT                                     3  ~30     !2
         60        ROPE_ADD                                      1  ~30     ~30, '+%3D%3D+'
         61        ROPE_END                                      2  ~29     ~30, !3
         62        SEND_VAL                                                 ~29
         63        SEND_VAL                                                 <true>
         64        DO_FCALL                                      0          
   75    65        INIT_FCALL                                               'vd'
         66        ROPE_INIT                                     5  ~34     'in_array%28'
         67        ROPE_ADD                                      1  ~34     ~34, !2
         68        ROPE_ADD                                      2  ~34     ~34, '%2C+%5B'
         69        ROPE_ADD                                      3  ~34     ~34, !3
         70        ROPE_END                                      4  ~33     ~34, '%5D%29'
         71        SEND_VAL                                                 ~33
         72        SEND_VAL                                                 <true>
         73        DO_FCALL                                      0          
   69    74      > JMP                                                      ->54
         75    >   FE_FREE                                                  $27
   78    76        ECHO                                                     '%0A'
   68    77      > JMP                                                      ->52
         78    >   FE_FREE                                                  $26
   79    79      > RETURN                                                   1

Function vd:
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 = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/Huc7t
function name:  vd
number of ops:  17
compiled vars:  !0 = $expr, !1 = $onlyTrue, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
   31     2        CONCAT                                           ~3      'return+', !0
          3        CONCAT                                           ~4      ~3, '%3B'
          4        INCLUDE_OR_EVAL                                  $5      ~4, EVAL
          5        ASSIGN                                                   !2, $5
   33     6      > JMPZ_EX                                          ~7      !1, ->9
          7    >   TYPE_CHECK                                  1014  ~8      !2
          8        BOOL                                             ~7      ~8
          9    > > JMPZ                                                     ~7, ->11
   34    10    > > RETURN                                                   null
   37    11    >   CONCAT                                           ~9      !0, '%3A+'
         12        ECHO                                                     ~9
   38    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
   39    16      > RETURN                                                   null

End of function vd

Class Str:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Huc7t
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E > > RETURN                                                   'A'
   26     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __tostring

End of class Str.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.02 ms | 1011 KiB | 24 Q