3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('zend.exception_ignore_args', 1); function main() { try { foo(false); } catch (Exception $ex) { echo $ex->getMessage() . PHP_EOL; } try { foo(true); } catch (Exception $ex) { echo $ex->getMessage() . PHP_EOL; } } function foo($ok) { $file = new SplFileObject('/tmp/hoge.txt', 'a'); if ($file->flock(LOCK_EX|LOCK_NB) == false) { throw new RuntimeException("Unable lock file"); } bar($file, $ok); // この関数を抜けたときにファイルは閉じられるはず } function bar(SplFileObject $file, $ok) { // なにか処理する if ($ok == false) { // 失敗したので例外を投げる throw new RuntimeException("oops!!!"); } echo "ok\n"; } main();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i0gXq
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'zend.exception_ignore_args'
          2        SEND_VAL                                                 1
          3        DO_ICALL                                                 
   42     4        INIT_FCALL                                               'main'
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function main:
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 = 42) Position 1 = 18
Branch analysis from position: 18
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 = 42) Position 1 = 18
Branch analysis from position: 18
Found catch point at position: 13
Branch analysis from position: 13
2 jumps found. (Code = 107) Position 1 = 14, Position 2 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i0gXq
function name:  main
number of ops:  19
compiled vars:  !0 = $ex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL_BY_NAME                                       'foo'
          1        SEND_VAL_EX                                              <false>
          2        DO_FCALL                                      0          
          3      > JMP                                                      ->9
    8     4  E > > CATCH                                       last         'Exception'
    9     5    >   INIT_METHOD_CALL                                         !0, 'getMessage'
          6        DO_FCALL                                      0  $2      
          7        CONCAT                                           ~3      $2, '%0A'
          8        ECHO                                                     ~3
   13     9    >   INIT_FCALL_BY_NAME                                       'foo'
         10        SEND_VAL_EX                                              <true>
         11        DO_FCALL                                      0          
         12      > JMP                                                      ->18
   14    13  E > > CATCH                                       last         'Exception'
   15    14    >   INIT_METHOD_CALL                                         !0, 'getMessage'
         15        DO_FCALL                                      0  $5      
         16        CONCAT                                           ~6      $5, '%0A'
         17        ECHO                                                     ~6
   17    18    > > RETURN                                                   null

End of function main

Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i0gXq
function name:  foo
number of ops:  20
compiled vars:  !0 = $ok, !1 = $file
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   21     1        NEW                                              $2      'SplFileObject'
          2        SEND_VAL_EX                                              '%2Ftmp%2Fhoge.txt'
          3        SEND_VAL_EX                                              'a'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $2
   22     6        INIT_METHOD_CALL                                         !1, 'flock'
          7        SEND_VAL_EX                                              6
          8        DO_FCALL                                      0  $5      
          9        BOOL_NOT                                         ~6      $5
         10      > JMPZ                                                     ~6, ->15
   23    11    >   NEW                                              $7      'RuntimeException'
         12        SEND_VAL_EX                                              'Unable+lock+file'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $7
   25    15    >   INIT_FCALL_BY_NAME                                       'bar'
         16        SEND_VAR_EX                                              !1
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0          
   28    19      > RETURN                                                   null

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i0gXq
function name:  bar
number of ops:  10
compiled vars:  !0 = $file, !1 = $ok
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   34     2        BOOL_NOT                                         ~2      !1
          3      > JMPZ                                                     ~2, ->8
   36     4    >   NEW                                              $3      'RuntimeException'
          5        SEND_VAL_EX                                              'oops%21%21%21'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $3
   39     8    >   ECHO                                                     'ok%0A'
   40     9      > RETURN                                                   null

End of function bar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.76 ms | 1005 KiB | 15 Q