3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(ticks=1); function tick_handler() { echo "tick_handler() called\n"; } function inverse($x) {tick_handler(); if (!$x) {tick_handler(); throw new Exception('Division by zero.');tick_handler(); } return 1/$x;tick_handler(); } 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/AF251
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/AF251
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 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AF251
function name:  inverse
number of ops:  24
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'tick_handler'
          2        DO_FCALL                                      0          
          3        TICKS                                                    
   10     4        BOOL_NOT                                         ~2      !0
          5      > JMPZ                                                     ~2, ->17
          6    >   INIT_FCALL                                               'tick_handler'
          7        DO_FCALL                                      0          
          8        TICKS                                                    
   11     9        NEW                                              $4      'Exception'
         10        SEND_VAL_EX                                              'Division+by+zero.'
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $4
         13*       TICKS                                                    
         14*       INIT_FCALL                                               'tick_handler'
         15*       DO_FCALL                                      0          
         16*       TICKS                                                    
   13    17    >   DIV                                              ~7      1, !0
         18      > RETURN                                                   ~7
         19*       TICKS                                                    
         20*       INIT_FCALL                                               'tick_handler'
         21*       DO_FCALL                                      0          
         22*       TICKS                                                    
   14    23*     > RETURN                                                   null

End of function inverse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.38 ms | 1394 KiB | 20 Q