3v4l.org

run code in 300+ PHP versions simultaneously
<?php restore_error_handler(); // funzione di gestione dell'errore function myErrorHandler ($errno, $errstr, $errfile, $errline) { switch ($errno) { case FATAL: echo "<b>FATAL</b> [$errno] $errstr<br>\n"; echo " Fatal error in line ".$errline." of file ".$errfile; echo ", PHP ".PHP_VERSION." (".PHP_OS.")<br>\n"; echo "Aborting...<br>\n"; @exit(); break; case ERROR: echo "<b>ERROR</b> [$errno] $errstr<br>\n"; break; case WARNING: echo "<b>WARNING</b> [$errno] $errstr<br>\n"; break; default: echo "Unkown error type: [$errno] $errstr<br>\n"; break; } } // funzione di prova del gestore di errore function scale_by_log ($vect, $scale) { if ( !is_numeric($scale) || $scale <= 0 ) trigger_error("log(x) for x <= 0 is undefined, you used: scale = $scale", FATAL); if (!is_array($vect)) { trigger_error("Incorrect input vector, array of values expected", ERROR); return null; } for ($i=0; $i<count($vect); $i++) { if (!is_numeric($vect[$i])) trigger_error("Value at position $i is not a number, using 0 (zero)", WARNING); $temp[$i] = log($scale) * $vect[$i]; } return $temp; } // configura il gestore dell'errore definito dall'utente $old_error_handler = set_error_handler("myErrorHandler"); // attiva alcuni errori, definendo prima un array misto con elementi non numerici echo "vector a\n"; $a = array(2,3,"foo",5.5,43.3,21.11); print_r($a); // genera il secondo array, generando un avviso echo "----\nvector b - a warning (b = log(PI) * a)\n"; $b = scale_by_log($a, M_PI); print_r($b); // questo è il problema, passiamo una stringa al posto di un array echo "----\nvector c - an error\n"; $c = scale_by_log("not array",2.3); var_dump($c); // errore critico, il log di zero o di un numero negativo non è definito echo "----\nvector d - fatal error\n"; $d = scale_by_log($a, -2.5); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DGDSF
function name:  (null)
number of ops:  36
compiled vars:  !0 = $old_error_handler, !1 = $a, !2 = $b, !3 = $c, !4 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'restore_error_handler'
          1        DO_ICALL                                                 
   46     2        INIT_FCALL                                               'set_error_handler'
          3        SEND_VAL                                                 'myErrorHandler'
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !0, $6
   49     6        ECHO                                                     'vector+a%0A'
   50     7        ASSIGN                                                   !1, <array>
   51     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   54    11        ECHO                                                     '----%0Avector+b+-+a+warning+%28b+%3D+log%28PI%29+%2A+a%29%0A'
   55    12        INIT_FCALL                                               'scale_by_log'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 3.14159
         15        DO_FCALL                                      0  $10     
         16        ASSIGN                                                   !2, $10
   56    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
   59    20        ECHO                                                     '----%0Avector+c+-+an+error%0A'
   60    21        INIT_FCALL                                               'scale_by_log'
         22        SEND_VAL                                                 'not+array'
         23        SEND_VAL                                                 2.3
         24        DO_FCALL                                      0  $13     
         25        ASSIGN                                                   !3, $13
   61    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                                 
   64    29        ECHO                                                     '----%0Avector+d+-+fatal+error%0A'
   65    30        INIT_FCALL                                               'scale_by_log'
         31        SEND_VAR                                                 !1
         32        SEND_VAL                                                 -2.5
         33        DO_FCALL                                      0  $16     
         34        ASSIGN                                                   !4, $16
   67    35      > RETURN                                                   1

Function myerrorhandler:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 37
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 14
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/DGDSF
function name:  myErrorHandler
number of ops:  52
compiled vars:  !0 = $errno, !1 = $errstr, !2 = $errfile, !3 = $errline
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    8     4        FETCH_CONSTANT                                   ~5      'FATAL'
          5        IS_EQUAL                                                 !0, ~5
          6      > JMPNZ                                                    ~4, ->14
   15     7    >   FETCH_CONSTANT                                   ~6      'ERROR'
          8        IS_EQUAL                                                 !0, ~6
          9      > JMPNZ                                                    ~4, ->30
   18    10    >   FETCH_CONSTANT                                   ~7      'WARNING'
         11        IS_EQUAL                                                 !0, ~7
         12      > JMPNZ                                                    ~4, ->37
         13    > > JMP                                                      ->44
    9    14    >   ROPE_INIT                                     5  ~9      '%3Cb%3EFATAL%3C%2Fb%3E+%5B'
         15        ROPE_ADD                                      1  ~9      ~9, !0
         16        ROPE_ADD                                      2  ~9      ~9, '%5D+'
         17        ROPE_ADD                                      3  ~9      ~9, !1
         18        ROPE_END                                      4  ~8      ~9, '%3Cbr%3E%0A'
         19        ECHO                                                     ~8
   10    20        CONCAT                                           ~12     '++Fatal+error+in+line+', !3
         21        CONCAT                                           ~13     ~12, '+of+file+'
         22        CONCAT                                           ~14     ~13, !2
         23        ECHO                                                     ~14
   11    24        ECHO                                                     '%2C+PHP+8.0.0+%28Linux%29%3Cbr%3E%0A'
   12    25        ECHO                                                     'Aborting...%3Cbr%3E%0A'
   13    26        BEGIN_SILENCE                                    ~15     
         27      > EXIT                                                     
         28*       END_SILENCE                                              ~15
   14    29*       JMP                                                      ->51
   16    30    >   ROPE_INIT                                     5  ~17     '%3Cb%3EERROR%3C%2Fb%3E+%5B'
         31        ROPE_ADD                                      1  ~17     ~17, !0
         32        ROPE_ADD                                      2  ~17     ~17, '%5D+'
         33        ROPE_ADD                                      3  ~17     ~17, !1
         34        ROPE_END                                      4  ~16     ~17, '%3Cbr%3E%0A'
         35        ECHO                                                     ~16
   17    36      > JMP                                                      ->51
   19    37    >   ROPE_INIT                                     5  ~21     '%3Cb%3EWARNING%3C%2Fb%3E+%5B'
         38        ROPE_ADD                                      1  ~21     ~21, !0
         39        ROPE_ADD                                      2  ~21     ~21, '%5D+'
         40        ROPE_ADD                                      3  ~21     ~21, !1
         41        ROPE_END                                      4  ~20     ~21, '%3Cbr%3E%0A'
         42        ECHO                                                     ~20
   20    43      > JMP                                                      ->51
   22    44    >   ROPE_INIT                                     5  ~25     'Unkown+error+type%3A+%5B'
         45        ROPE_ADD                                      1  ~25     ~25, !0
         46        ROPE_ADD                                      2  ~25     ~25, '%5D+'
         47        ROPE_ADD                                      3  ~25     ~25, !1
         48        ROPE_END                                      4  ~24     ~25, '%3Cbr%3E%0A'
         49        ECHO                                                     ~24
   23    50      > JMP                                                      ->51
   25    51    > > RETURN                                                   null

End of function myerrorhandler

Function scale_by_log:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 28
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 42
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 28
Branch analysis from position: 53
Branch analysis from position: 28
Branch analysis from position: 42
Branch analysis from position: 17
Branch analysis from position: 9
filename:       /in/DGDSF
function name:  scale_by_log
number of ops:  55
compiled vars:  !0 = $vect, !1 = $scale, !2 = $i, !3 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   29     2        INIT_FCALL                                               'is_numeric'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $4      
          5        BOOL_NOT                                         ~5      $4
          6      > JMPNZ_EX                                         ~5      ~5, ->9
          7    >   IS_SMALLER_OR_EQUAL                              ~6      !1, 0
          8        BOOL                                             ~5      ~6
          9    > > JMPZ                                                     ~5, ->17
   30    10    >   INIT_FCALL                                               'trigger_error'
         11        NOP                                                      
         12        FAST_CONCAT                                      ~7      'log%28x%29+for+x+%3C%3D+0+is+undefined%2C+you+used%3A+scale+%3D+', !1
         13        SEND_VAL                                                 ~7
   31    14        FETCH_CONSTANT                                   ~8      'FATAL'
         15        SEND_VAL                                                 ~8
         16        DO_ICALL                                                 
   32    17    >   TYPE_CHECK                                  128  ~10     !0
         18        BOOL_NOT                                         ~11     ~10
         19      > JMPZ                                                     ~11, ->26
   33    20    >   INIT_FCALL                                               'trigger_error'
         21        SEND_VAL                                                 'Incorrect+input+vector%2C+array+of+values+expected'
         22        FETCH_CONSTANT                                   ~12     'ERROR'
         23        SEND_VAL                                                 ~12
         24        DO_ICALL                                                 
   34    25      > RETURN                                                   null
   36    26    >   ASSIGN                                                   !2, 0
         27      > JMP                                                      ->50
   37    28    >   INIT_FCALL                                               'is_numeric'
         29        FETCH_DIM_R                                      ~15     !0, !2
         30        SEND_VAL                                                 ~15
         31        DO_ICALL                                         $16     
         32        BOOL_NOT                                         ~17     $16
         33      > JMPZ                                                     ~17, ->42
   38    34    >   INIT_FCALL                                               'trigger_error'
         35        ROPE_INIT                                     3  ~19     'Value+at+position+'
         36        ROPE_ADD                                      1  ~19     ~19, !2
         37        ROPE_END                                      2  ~18     ~19, '+is+not+a+number%2C+using+0+%28zero%29'
         38        SEND_VAL                                                 ~18
   39    39        FETCH_CONSTANT                                   ~21     'WARNING'
         40        SEND_VAL                                                 ~21
         41        DO_ICALL                                                 
   40    42    >   INIT_FCALL                                               'log'
         43        SEND_VAR                                                 !1
         44        DO_ICALL                                         $24     
         45        FETCH_DIM_R                                      ~25     !0, !2
         46        MUL                                              ~26     $24, ~25
         47        ASSIGN_DIM                                               !3, !2
         48        OP_DATA                                                  ~26
   36    49        PRE_INC                                                  !2
         50    >   COUNT                                            ~28     !0
         51        IS_SMALLER                                               !2, ~28
         52      > JMPNZ                                                    ~29, ->28
   42    53    > > RETURN                                                   !3
   43    54*     > RETURN                                                   null

End of function scale_by_log

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.27 ms | 1411 KiB | 30 Q