3v4l.org

run code in 500+ PHP versions simultaneously
<?php function test($f) { try { $f(); echo "No error?\n"; } catch (TypeError|ValueError $e) { if (strpos($e->getMessage(), '($WRONG_SCOPE_')) { echo "Bad error! ", $e->getMessage(), "\n"; } else { echo "Good error.\n"; } } } test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < "x"); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < []); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + "x"); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + []);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J00BTp
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                                   'test'
          1        DECLARE_LAMBDA_FUNCTION                              ~0      [0]
          2        SEND_VAL                                                     ~0
          3        DO_FCALL                                          0          
   16     4        INIT_FCALL                                                   'test'
          5        DECLARE_LAMBDA_FUNCTION                              ~2      [1]
          6        SEND_VAL                                                     ~2
          7        DO_FCALL                                          0          
   17     8        INIT_FCALL                                                   'test'
          9        DECLARE_LAMBDA_FUNCTION                              ~4      [2]
         10        SEND_VAL                                                     ~4
         11        DO_FCALL                                          0          
   18    12        INIT_FCALL                                                   'test'
         13        DECLARE_LAMBDA_FUNCTION                              ~6      [3]
         14        SEND_VAL                                                     ~6
         15        DO_FCALL                                          0          
         16      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J00BTp
function name:  {closure:/in/J00BTp:15}
number of ops:  8
compiled vars:  !0 = $WRONG_SCOPE_1, !1 = $WRONG_SCOPE_2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV_INIT                                            !0      0
          1        RECV_INIT                                            !1      0
          2        INIT_FCALL_BY_NAME                                           'gmp_init'
          3        SEND_VAL_EX                                                  1
          4        DO_FCALL                                          0  $2      
          5        IS_SMALLER                                           ~3      $2, 'x'
          6      > RETURN                                                       ~3
          7*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J00BTp
function name:  {closure:/in/J00BTp:16}
number of ops:  8
compiled vars:  !0 = $WRONG_SCOPE_1, !1 = $WRONG_SCOPE_2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                            !0      0
          1        RECV_INIT                                            !1      0
          2        INIT_FCALL_BY_NAME                                           'gmp_init'
          3        SEND_VAL_EX                                                  1
          4        DO_FCALL                                          0  $2      
          5        IS_SMALLER                                           ~3      $2, <array>
          6      > RETURN                                                       ~3
          7*     > RETURN                                                       null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J00BTp
function name:  {closure:/in/J00BTp:17}
number of ops:  8
compiled vars:  !0 = $WRONG_SCOPE_1, !1 = $WRONG_SCOPE_2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV_INIT                                            !0      0
          1        RECV_INIT                                            !1      0
          2        INIT_FCALL_BY_NAME                                           'gmp_init'
          3        SEND_VAL_EX                                                  1
          4        DO_FCALL                                          0  $2      
          5        ADD                                                  ~3      $2, 'x'
          6      > RETURN                                                       ~3
          7*     > RETURN                                                       null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J00BTp
function name:  {closure:/in/J00BTp:18}
number of ops:  8
compiled vars:  !0 = $WRONG_SCOPE_1, !1 = $WRONG_SCOPE_2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV_INIT                                            !0      0
          1        RECV_INIT                                            !1      0
          2        INIT_FCALL_BY_NAME                                           'gmp_init'
          3        SEND_VAL_EX                                                  1
          4        DO_FCALL                                          0  $2      
          5        ADD                                                  ~3      $2, <array>
          6      > RETURN                                                       ~3
          7*     > RETURN                                                       null

End of Dynamic Function 3

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 5
Branch analysis from position: 5
2 jumps found. (Code = 107) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
Found catch point at position: 7
Branch analysis from position: 7
filename:       /in/J00BTp
function name:  test
number of ops:  20
compiled vars:  !0 = $f, !1 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_DYNAMIC_CALL                                            !0
          2        DO_FCALL                                          0          
    6     3        ECHO                                                         'No+error%3F%0A'
          4      > JMP                                                          ->19
    7     5  E > > CATCH                                                        'TypeError', ->7
          6    > > JMP                                                          ->8
          7  E > > CATCH                                           last         'ValueError'
    8     8    >   INIT_METHOD_CALL                                             !1, 'getMessage'
          9        DO_FCALL                                          0  $3      
         10        FRAMELESS_ICALL_2                strpos              ~4      $3, '%28%24WRONG_SCOPE_'
         11      > JMPZ                                                         ~4, ->18
    9    12    >   ECHO                                                         'Bad+error%21+'
         13        INIT_METHOD_CALL                                             !1, 'getMessage'
         14        DO_FCALL                                          0  $5      
         15        ECHO                                                         $5
         16        ECHO                                                         '%0A'
    8    17      > JMP                                                          ->19
   11    18    >   ECHO                                                         'Good+error.%0A'
   14    19    > > RETURN                                                       null

End of function test

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
224.84 ms | 2020 KiB | 17 Q