3v4l.org

run code in 300+ PHP versions simultaneously
<?php function exception_error_handler($severity, $message, $file, $line) { if (!(error_reporting() & $severity)) { // This error code is not included in error_reporting return; } throw new ErrorException($message, 0, $severity, $file, $line); } set_error_handler("exception_error_handler"); $o=new StdClass(); $o->f=function(){ echo "i ran!"; }; try{ $o->f(); }catch(Throwable $ex){ echo 'didn\'t work: $o->f()',PHP_EOL; } try{ call_user_func([$o,'f']); }catch(Throwable $ex){ echo 'didn\'t work: call_user_func([$o,\'f\'])',PHP_EOL; } try{ get_object_vars($o)['f'](); }catch(Throwable $ex){var_dump($ex); echo 'didn\'t work: get_object_vars($o)[\'f\']()',PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 12
Branch analysis from position: 12
2 jumps found. (Code = 107) Position 1 = 13, Position 2 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Found catch point at position: 20
Branch analysis from position: 20
2 jumps found. (Code = 107) Position 1 = 21, Position 2 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Found catch point at position: 30
Branch analysis from position: 30
2 jumps found. (Code = 107) Position 1 = 31, Position 2 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MppBE
function name:  (null)
number of ops:  37
compiled vars:  !0 = $o, !1 = $ex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'set_error_handler'
          1        SEND_VAL                                                 'exception_error_handler'
          2        DO_ICALL                                                 
   11     3        NEW                                              $3      'StdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $3
   12     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMppBE%3A12%240'
          7        ASSIGN_OBJ                                               !0, 'f'
   14     8        OP_DATA                                                  ~7
   16     9        INIT_METHOD_CALL                                         !0, 'f'
         10        DO_FCALL                                      0          
         11      > JMP                                                      ->15
   17    12  E > > CATCH                                       last         'Throwable'
   18    13    >   ECHO                                                     'didn%27t+work%3A+%24o-%3Ef%28%29'
         14        ECHO                                                     '%0A'
   21    15    >   INIT_ARRAY                                       ~9      !0
         16        ADD_ARRAY_ELEMENT                                ~9      'f'
         17        INIT_USER_CALL                                0          'call_user_func', ~9
         18        DO_FCALL                                      0          
         19      > JMP                                                      ->23
   22    20  E > > CATCH                                       last         'Throwable'
   23    21    >   ECHO                                                     'didn%27t+work%3A+call_user_func%28%5B%24o%2C%27f%27%5D%29'
         22        ECHO                                                     '%0A'
   26    23    >   INIT_FCALL                                               'get_object_vars'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $11     
         26        FETCH_DIM_R                                      ~12     $11, 'f'
         27        INIT_DYNAMIC_CALL                                        ~12
         28        DO_FCALL                                      0          
         29      > JMP                                                      ->36
   27    30  E > > CATCH                                       last         'Throwable'
         31    >   INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                                 
   28    34        ECHO                                                     'didn%27t+work%3A+get_object_vars%28%24o%29%5B%27f%27%5D%28%29'
         35        ECHO                                                     '%0A'
   29    36    > > RETURN                                                   1

Function exception_error_handler:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/MppBE
function name:  exception_error_handler
number of ops:  19
compiled vars:  !0 = $severity, !1 = $message, !2 = $file, !3 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    3     4        INIT_FCALL                                               'error_reporting'
          5        DO_ICALL                                         $4      
          6        BW_AND                                           ~5      !0, $4
          7        BOOL_NOT                                         ~6      ~5
          8      > JMPZ                                                     ~6, ->10
    5     9    > > RETURN                                                   null
    7    10    >   NEW                                              $7      'ErrorException'
         11        SEND_VAR_EX                                              !1
         12        SEND_VAL_EX                                              0
         13        SEND_VAR_EX                                              !0
         14        SEND_VAR_EX                                              !2
         15        SEND_VAR_EX                                              !3
         16        DO_FCALL                                      0          
         17      > THROW                                         0          $7
    8    18*     > RETURN                                                   null

End of function exception_error_handler

Function %00%7Bclosure%7D%2Fin%2FMppBE%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MppBE
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ECHO                                                     'i+ran%21'
   14     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMppBE%3A12%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
189.55 ms | 1400 KiB | 21 Q