3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Exception1 extends Exception { } class Exception2 extends Exception { } function foo($case) { $e = null; try { if ($case == 1) { echo "throw exception 1\n"; throw new Exception1(); } else if ($case == 2) { echo "throw exception 2\n"; throw new Exception2(); } else { echo "successful\n"; return "success"; } } catch (Exception1 $e) { echo "caught exception 1\n"; return "failure 1"; } catch (Exception2 $e) { echo "caught exception 2\n"; return "failure 2"; } finally { if ($e) { echo "finally with error\n"; } else { echo "finally with success\n"; } } } echo "Success:\n"; echo "Returns: " . foo(0) . "\n"; echo "\nCase 1 throws Exception1:\n"; echo "Returns: " . foo(1) . "\n"; echo "\nCase 2 throws Exception2:\n"; echo "Returns: " . foo(2) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FKLcO
function name:  (null)
number of ops:  22
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   ECHO                                                     'Success%3A%0A'
   35     1        INIT_FCALL                                               'foo'
          2        SEND_VAL                                                 0
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      'Returns%3A+', $0
          5        CONCAT                                           ~2      ~1, '%0A'
          6        ECHO                                                     ~2
   36     7        ECHO                                                     '%0ACase+1+throws+Exception1%3A%0A'
   37     8        INIT_FCALL                                               'foo'
          9        SEND_VAL                                                 1
         10        DO_FCALL                                      0  $3      
         11        CONCAT                                           ~4      'Returns%3A+', $3
         12        CONCAT                                           ~5      ~4, '%0A'
         13        ECHO                                                     ~5
   38    14        ECHO                                                     '%0ACase+2+throws+Exception2%3A%0A'
   39    15        INIT_FCALL                                               'foo'
         16        SEND_VAL                                                 2
         17        DO_FCALL                                      0  $6      
         18        CONCAT                                           ~7      'Returns%3A+', $6
         19        CONCAT                                           ~8      ~7, '%0A'
         20        ECHO                                                     ~8
         21      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 162) Position 1 = 31, Position 2 = 18
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 20
Branch analysis from position: 20
2 jumps found. (Code = 107) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 162) Position 1 = 31, Position 2 = 23
Branch analysis from position: 31
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 107) Position 1 = 26, Position 2 = -2
Branch analysis from position: 26
2 jumps found. (Code = 162) Position 1 = 31, Position 2 = 28
Branch analysis from position: 31
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 25
Branch analysis from position: 25
filename:       /in/FKLcO
function name:  foo
number of ops:  37
compiled vars:  !0 = $case, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, null
    9     2        IS_EQUAL                                                 !0, 1
          3      > JMPZ                                                     ~4, ->9
   10     4    >   ECHO                                                     'throw+exception+1%0A'
   11     5        NEW                                              $5      'Exception1'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $5
    9     8*       JMP                                                      ->19
   12     9    >   IS_EQUAL                                                 !0, 2
         10      > JMPZ                                                     ~7, ->16
   13    11    >   ECHO                                                     'throw+exception+2%0A'
   14    12        NEW                                              $8      'Exception2'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $8
   12    15*       JMP                                                      ->19
   16    16    >   ECHO                                                     'successful%0A'
   17    17      > FAST_CALL                                                ->31
         18    > > RETURN                                                   'success'
         19*       JMP                                                      ->29
   19    20  E > > CATCH                                                    'Exception1', ->25
   20    21    >   ECHO                                                     'caught+exception+1%0A'
   21    22      > FAST_CALL                                                ->31
         23    > > RETURN                                                   'failure+1'
         24*       JMP                                                      ->29
   22    25  E > > CATCH                                       last         'Exception2'
   23    26    >   ECHO                                                     'caught+exception+2%0A'
   24    27      > FAST_CALL                                                ->31
         28    > > RETURN                                                   'failure+2'
   25    29*       FAST_CALL                                                ->31
         30*       JMP                                                      ->36
   26    31    > > JMPZ                                                     !1, ->34
   27    32    >   ECHO                                                     'finally+with+error%0A'
   26    33      > JMP                                                      ->35
   29    34    >   ECHO                                                     'finally+with+success%0A'
         35    > > FAST_RET                                                 
   32    36*     > RETURN                                                   null

End of function foo

Class Exception1: [no user functions]
Class Exception2: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.83 ms | 1016 KiB | 16 Q