3v4l.org

run code in 300+ PHP versions simultaneously
<?php //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(Throwable $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 an error try { array_diff([], [$stdObject]); }catch(Throwable $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(Throwable $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 = 12
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) 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 = 42) Position 1 = 25
Branch analysis from position: 25
Found catch point at position: 19
Branch analysis from position: 19
2 jumps found. (Code = 107) Position 1 = 20, Position 2 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Found catch point at position: 33
Branch analysis from position: 33
2 jumps found. (Code = 107) Position 1 = 34, Position 2 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dc9Pu
function name:  (null)
number of ops:  40
compiled vars:  !0 = $stdObject, !1 = $hello, !2 = $ee
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   12     3        CAST                                          6  ~6      !0
          4        ASSIGN                                                   !1, ~6
          5      > JMP                                                      ->12
   13     6  E > > CATCH                                       last         'Throwable'
   15     7    >   INIT_METHOD_CALL                                         !2, 'getMessage'
          8        DO_FCALL                                      0  $8      
          9        CONCAT                                           ~9      'Catched+exception%3A+', $8
         10        CONCAT                                           ~10     ~9, '%0A'
         11        ECHO                                                     ~10
   18    12    >   ECHO                                                     '%0A----------%0A'
   22    13        INIT_FCALL                                               'array_diff'
         14        SEND_VAL                                                 <array>
         15        INIT_ARRAY                                       ~11     !0
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                                 
         18      > JMP                                                      ->25
   23    19  E > > CATCH                                       last         'Throwable'
   25    20    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         21        DO_FCALL                                      0  $13     
         22        CONCAT                                           ~14     'Catched+exception%3A+', $13
         23        CONCAT                                           ~15     ~14, '%0A'
         24        ECHO                                                     ~15
   28    25    >   ECHO                                                     '%0A----------%0A'
   32    26        INIT_FCALL                                               'array_diff'
         27        INIT_ARRAY                                       ~16     !0
         28        SEND_VAL                                                 ~16
         29        INIT_ARRAY                                       ~17     !0
         30        SEND_VAL                                                 ~17
         31        DO_ICALL                                                 
         32      > JMP                                                      ->39
   33    33  E > > CATCH                                       last         'Throwable'
   35    34    >   INIT_METHOD_CALL                                         !2, 'getMessage'
         35        DO_FCALL                                      0  $19     
         36        CONCAT                                           ~20     'Catched+exception%3A+', $19
         37        CONCAT                                           ~21     ~20, '%0A'
         38        ECHO                                                     ~21
   36    39    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.7 ms | 1400 KiB | 15 Q