3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(ticks=1); function tick_handler() { echo "tick_handler() called\n"; } function inverse($x) { if (1/0) {tick_handler(); throw new Exception('Division by zero.'); } return 1/$x; } try { echo inverse(5) . "\n"; echo inverse(0) . "\n"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } echo inverse(0) . "\n"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 14
Branch analysis from position: 14
2 jumps found. (Code = 107) Position 1 = 15, Position 2 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JBNkZ
function name:  (null)
number of ops:  30
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   TICKS                                                    
   17     1        INIT_FCALL                                               'inverse'
          2        SEND_VAL                                                 5
          3        DO_FCALL                                      0  $1      
          4        CONCAT                                           ~2      $1, '%0A'
          5        ECHO                                                     ~2
          6        TICKS                                                    
   19     7        INIT_FCALL                                               'inverse'
          8        SEND_VAL                                                 0
          9        DO_FCALL                                      0  $3      
         10        CONCAT                                           ~4      $3, '%0A'
         11        ECHO                                                     ~4
         12        TICKS                                                    
         13      > JMP                                                      ->23
   22    14  E > > CATCH                                       last         'Exception'
   23    15    >   ECHO                                                     'Caught+exception%3A+'
         16        TICKS                                                    
         17        INIT_METHOD_CALL                                         !0, 'getMessage'
         18        DO_FCALL                                      0  $5      
         19        ECHO                                                     $5
         20        TICKS                                                    
         21        ECHO                                                     '%0A'
         22        TICKS                                                    
   25    23    >   INIT_FCALL                                               'inverse'
         24        SEND_VAL                                                 0
         25        DO_FCALL                                      0  $6      
         26        CONCAT                                           ~7      $6, '%0A'
         27        ECHO                                                     ~7
         28        TICKS                                                    
   28    29      > RETURN                                                   1

Function tick_handler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JBNkZ
function name:  tick_handler
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'tick_handler%28%29+called%0A'
          1        TICKS                                                    
    6     2      > RETURN                                                   null

End of function tick_handler

Function inverse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JBNkZ
function name:  inverse
number of ops:  15
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        DIV                                              ~1      1, 0
          2      > JMPZ                                                     ~1, ->11
          3    >   INIT_FCALL                                               'tick_handler'
          4        DO_FCALL                                      0          
          5        TICKS                                                    
   11     6        NEW                                              $3      'Exception'
          7        SEND_VAL_EX                                              'Division+by+zero.'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $3
         10*       TICKS                                                    
   13    11    >   DIV                                              ~5      1, !0
         12      > RETURN                                                   ~5
         13*       TICKS                                                    
   14    14*     > RETURN                                                   null

End of function inverse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.47 ms | 1402 KiB | 17 Q