3v4l.org

run code in 300+ PHP versions simultaneously
<?php //We set an error handler to throw an ErrorException whenever an error is triggered set_error_handler(function (int $severity, string $message, string $filename, int $line) { echo "Throwing ErrorException\n"; throw new ErrorException($message, 0, $severity, $filename, $line); }); //We're going to test this error handler passing wrong arguments to array_diff //array_diff compares array items CASTING them to string. Yes, it is retarded. //http://php.net/manual/en/function.array-diff.php //We declare an object that can't be cast to string $stdObject = new stdClass(); //First case: let's trigger an error try { array_diff([$stdObject], [$stdObject]); }catch(ErrorException $ee){ //Handler is called, exception is thrown and catched here. Yay! echo "Catched exception: " . $ee->getMessage() . "\n"; } echo "\n----------\n"; //Second case: let's trigger another slightly different error try { array_diff([$stdObject], [$stdObject]); }catch(ErrorException $ee){ //Handler is called, exception is thrown but... IT IS NOT CATCHED! echo "Catched exception: " . $ee->getMessage() . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
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 = 42) Position 1 = 34
Branch analysis from position: 34
Found catch point at position: 28
Branch analysis from position: 28
2 jumps found. (Code = 107) Position 1 = 29, Position 2 = -2
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rti4f
function name:  (null)
number of ops:  35
compiled vars:  !0 = $stdObject, !1 = $ee
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'set_error_handler'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Frti4f%3A4%240'
    7     2        SEND_VAL                                                 ~2
          3        DO_ICALL                                                 
   14     4        NEW                                              $4      'stdClass'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $4
   18     7        INIT_FCALL                                               'array_diff'
          8        INIT_ARRAY                                       ~7      !0
          9        SEND_VAL                                                 ~7
         10        INIT_ARRAY                                       ~8      !0
         11        SEND_VAL                                                 ~8
         12        DO_ICALL                                                 
         13      > JMP                                                      ->20
   19    14  E > > CATCH                                       last         'ErrorException'
   21    15    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         16        DO_FCALL                                      0  $10     
         17        CONCAT                                           ~11     'Catched+exception%3A+', $10
         18        CONCAT                                           ~12     ~11, '%0A'
         19        ECHO                                                     ~12
   24    20    >   ECHO                                                     '%0A----------%0A'
   28    21        INIT_FCALL                                               'array_diff'
         22        INIT_ARRAY                                       ~13     !0
         23        SEND_VAL                                                 ~13
         24        INIT_ARRAY                                       ~14     !0
         25        SEND_VAL                                                 ~14
         26        DO_ICALL                                                 
         27      > JMP                                                      ->34
   29    28  E > > CATCH                                       last         'ErrorException'
   31    29    >   INIT_METHOD_CALL                                         !1, 'getMessage'
         30        DO_FCALL                                      0  $16     
         31        CONCAT                                           ~17     'Catched+exception%3A+', $16
         32        CONCAT                                           ~18     ~17, '%0A'
         33        ECHO                                                     ~18
   32    34    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Frti4f%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/rti4f
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $severity, !1 = $message, !2 = $filename, !3 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    5     4        ECHO                                                     'Throwing+ErrorException%0A'
    6     5        NEW                                              $4      'ErrorException'
          6        SEND_VAR_EX                                              !1
          7        SEND_VAL_EX                                              0
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !2
         10        SEND_VAR_EX                                              !3
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $4
    7    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Frti4f%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.92 ms | 1400 KiB | 17 Q