3v4l.org

run code in 500+ PHP versions simultaneously
<?php echo '----- Backed integer enum -----'.PHP_EOL; enum DayOfWeekInt : int { case Monday = 1; case Tuesday = 2; case Wednesday = 3; case Thursday = 4; case Friday = 5; case Saturday = 6; case Sunday = 7; } $var = DayOfWeekInt::Monday; try { echo '--- intval($var) --'.PHP_EOL; echo intval($var); } catch (\Throwable $ex) { echo $ex; } echo PHP_EOL; try { echo '--- (int) $var ---'.PHP_EOL; echo (int) $var; } catch (\Throwable $ex) { echo $ex; } echo PHP_EOL; echo PHP_EOL; echo '----- Backed string enum -----'.PHP_EOL; enum DayofWeekString : string { case Monday = 'monday'; case Tuesday = 'tuesday'; case Wednesday = 'wednesday'; case Thursday = 'thursday'; case Friday = 'friday'; case Saturday = 'saturday'; case Sunday = 'sunday'; } $var = DayofWeekString::Monday; try { echo '--- strval($var) ---'.PHP_EOL; echo strval($var); } catch (\Throwable $ex) { echo $ex; } echo PHP_EOL; try { echo '--- (string) $var ---'.PHP_EOL; echo (string) $var; } catch (\Throwable $ex) { echo $ex; } echo PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 8
Branch analysis from position: 8
2 jumps found. (Code = 107) Position 1 = 9, Position 2 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Found catch point at position: 15
Branch analysis from position: 15
2 jumps found. (Code = 107) Position 1 = 16, Position 2 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Found catch point at position: 27
Branch analysis from position: 27
2 jumps found. (Code = 107) Position 1 = 28, Position 2 = -2
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Found catch point at position: 34
Branch analysis from position: 34
2 jumps found. (Code = 107) Position 1 = 35, Position 2 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pfXH4
function name:  (null)
number of ops:  38
compiled vars:  !0 = $var, !1 = $ex
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ECHO                                                         '-----+Backed+integer+enum+-----%0A'
    4     1        DECLARE_CLASS                                                'dayofweekint'
   14     2        FETCH_CLASS_CONSTANT                                 ~2      'DayOfWeekInt', 'Monday'
          3        ASSIGN                                                       !0, ~2
   17     4        ECHO                                                         '---+intval%28%24var%29+--%0A'
   18     5        CAST                                              4  ~4      !0
          6        ECHO                                                         ~4
          7      > JMP                                                          ->10
   19     8  E > > CATCH                                           last         'Throwable'
   20     9    >   ECHO                                                         !1
   22    10    >   ECHO                                                         '%0A'
   25    11        ECHO                                                         '---+%28int%29+%24var+---%0A'
   26    12        CAST                                              4  ~5      !0
         13        ECHO                                                         ~5
         14      > JMP                                                          ->17
   27    15  E > > CATCH                                           last         'Throwable'
   28    16    >   ECHO                                                         !1
   30    17    >   ECHO                                                         '%0A'
   32    18        ECHO                                                         '%0A'
   33    19        ECHO                                                         '-----+Backed+string+enum+-----%0A'
   34    20        DECLARE_CLASS                                                'dayofweekstring'
   44    21        FETCH_CLASS_CONSTANT                                 ~6      'DayofWeekString', 'Monday'
         22        ASSIGN                                                       !0, ~6
   47    23        ECHO                                                         '---+strval%28%24var%29+---%0A'
   48    24        CAST                                              6  ~8      !0
         25        ECHO                                                         ~8
         26      > JMP                                                          ->29
   49    27  E > > CATCH                                           last         'Throwable'
   50    28    >   ECHO                                                         !1
   52    29    >   ECHO                                                         '%0A'
   55    30        ECHO                                                         '---+%28string%29+%24var+---%0A'
   56    31        CAST                                              6  ~9      !0
         32        ECHO                                                         ~9
         33      > JMP                                                          ->36
   57    34  E > > CATCH                                           last         'Throwable'
   58    35    >   ECHO                                                         !1
   60    36    >   ECHO                                                         '%0A'
   61    37      > RETURN                                                       1

Class DayOfWeekInt: [no user functions]
Class DayofWeekString: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
173.68 ms | 1408 KiB | 13 Q