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. No, it's not the lol here. //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 { $hello = (string) $stdObject; }catch(ErrorException $ee){ //Handler is called, exception is thrown and catched here. Yay! echo "Catched exception: " . $ee->getMessage() . "\n"; } //Second case: let's trigger an error try { array_diff([], [$stdObject]); }catch(ErrorException $ee){ //Handler is called, exception is thrown and catched here. Yay! echo "Catched exception: " . $ee->getMessage() . "\n"; } echo "\n----------\n"; //Third case: let's trigger a 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 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 10
Branch analysis from position: 10
2 jumps found. (Code = 107) Position 1 = 11, Position 2 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Found catch point at position: 22
Branch analysis from position: 22
2 jumps found. (Code = 107) Position 1 = 23, Position 2 = -2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Found catch point at position: 36
Branch analysis from position: 36
2 jumps found. (Code = 107) Position 1 = 37, Position 2 = -2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9qMN1
function name:  (null)
number of ops:  43
compiled vars:  !0 = $stdObject, !1 = $hello, !2 = $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%2F9qMN1%3A4%240'
    7     2        SEND_VAL                                                 ~3
          3        DO_ICALL                                                 
   14     4        NEW                                              $5      'stdClass'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $5
   18     7        CAST                                          6  ~8      !0
          8        ASSIGN                                                   !1, ~8
          9      > JMP                                                      ->16
   19    10  E > > CATCH                                       last         'ErrorException'
   21    11    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         12        DO_FCALL                                      0  $10     
         13        CONCAT                                           ~11     'Catched+exception%3A+', $10
         14        CONCAT                                           ~12     ~11, '%0A'
         15        ECHO                                                     ~12
   26    16    >   INIT_FCALL                                               'array_diff'
         17        SEND_VAL                                                 <array>
         18        INIT_ARRAY                                       ~13     !0
         19        SEND_VAL                                                 ~13
         20        DO_ICALL                                                 
         21      > JMP                                                      ->28
   27    22  E > > CATCH                                       last         'ErrorException'
   29    23    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         24        DO_FCALL                                      0  $15     
         25        CONCAT                                           ~16     'Catched+exception%3A+', $15
         26        CONCAT                                           ~17     ~16, '%0A'
         27        ECHO                                                     ~17
   32    28    >   ECHO                                                     '%0A----------%0A'
   36    29        INIT_FCALL                                               'array_diff'
         30        INIT_ARRAY                                       ~18     !0
         31        SEND_VAL                                                 ~18
         32        INIT_ARRAY                                       ~19     !0
         33        SEND_VAL                                                 ~19
         34        DO_ICALL                                                 
         35      > JMP                                                      ->42
   37    36  E > > CATCH                                       last         'ErrorException'
   39    37    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         38        DO_FCALL                                      0  $21     
         39        CONCAT                                           ~22     'Catched+exception%3A+', $21
         40        CONCAT                                           ~23     ~22, '%0A'
         41        ECHO                                                     ~23
   40    42    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F9qMN1%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/9qMN1
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%2F9qMN1%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.38 ms | 1400 KiB | 17 Q