3v4l.org

run code in 300+ PHP versions simultaneously
<?php function exception() { try { throw new Exception("test exception"); } catch(Exception $e) { echo "exception caught where thrown: ".$e->getMessage(); } } function caller($closure) { try { $closure(); } catch(Exception $e) { echo "exception caught in caller: ".$e->getMessage(); } } $closure = function() { try { exception(); } catch(Exception $e) { echo "exception caught in closure: ".$e->getMessage(); } }; try { caller($closure); } catch(Exception $e) { echo "exception caught: ".$e->getMessage(); } exit();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 79) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/gj7LD
function name:  (null)
number of ops:  13
compiled vars:  !0 = $closure, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fgj7LD%3A19%240'
          1        ASSIGN                                                   !0, ~2
   28     2        INIT_FCALL                                               'caller'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0          
          5      > JMP                                                      ->11
   29     6  E > > CATCH                                       last         'Exception'
   30     7    >   INIT_METHOD_CALL                                         !1, 'getMessage'
          8        DO_FCALL                                      0  $5      
          9        CONCAT                                           ~6      'exception+caught%3A+', $5
         10        ECHO                                                     ~6
   32    11    > > EXIT                                                     
         12*     > RETURN                                                   1

Function exception:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 5
Branch analysis from position: 5
2 jumps found. (Code = 107) Position 1 = 6, Position 2 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gj7LD
function name:  exception
number of ops:  11
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   NEW                                              $1      'Exception'
          1        SEND_VAL_EX                                              'test+exception'
          2        DO_FCALL                                      0          
          3      > THROW                                         0          $1
          4*       JMP                                                      ->10
    7     5  E > > CATCH                                       last         'Exception'
    8     6    >   INIT_METHOD_CALL                                         !0, 'getMessage'
          7        DO_FCALL                                      0  $3      
          8        CONCAT                                           ~4      'exception+caught+where+thrown%3A+', $3
          9        ECHO                                                     ~4
   10    10      > RETURN                                                   null

End of function exception

Function caller:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 4
Branch analysis from position: 4
2 jumps found. (Code = 107) Position 1 = 5, Position 2 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gj7LD
function name:  caller
number of ops:  10
compiled vars:  !0 = $closure, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0          
          3      > JMP                                                      ->9
   15     4  E > > CATCH                                       last         'Exception'
   16     5    >   INIT_METHOD_CALL                                         !1, 'getMessage'
          6        DO_FCALL                                      0  $3      
          7        CONCAT                                           ~4      'exception+caught+in+caller%3A+', $3
          8        ECHO                                                     ~4
   18     9    > > RETURN                                                   null

End of function caller

Function %00%7Bclosure%7D%2Fin%2Fgj7LD%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 3
Branch analysis from position: 3
2 jumps found. (Code = 107) Position 1 = 4, Position 2 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gj7LD
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'exception'
          1        DO_FCALL                                      0          
          2      > JMP                                                      ->8
   22     3  E > > CATCH                                       last         'Exception'
   23     4    >   INIT_METHOD_CALL                                         !0, 'getMessage'
          5        DO_FCALL                                      0  $2      
          6        CONCAT                                           ~3      'exception+caught+in+closure%3A+', $2
          7        ECHO                                                     ~3
   25     8    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fgj7LD%3A19%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.01 ms | 1403 KiB | 15 Q