3v4l.org

run code in 300+ PHP versions simultaneously
<?php // ridefinisce la costante dell'errore utente - solo PHP 4 define (FATAL,E_USER_ERROR); define (ERROR,E_USER_WARNING); define (WARNING,E_USER_NOTICE); // configura il livello di restituzione errore per questo script error_reporting (FATAL | ERROR | WARNING); // 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"; 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/YWAMt
function name:  (null)
number of ops:  57
compiled vars:  !0 = $old_error_handler, !1 = $a, !2 = $b, !3 = $c, !4 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'define'
          1        FETCH_CONSTANT                                   ~5      'FATAL'
          2        SEND_VAL                                                 ~5
          3        SEND_VAL                                                 256
          4        DO_ICALL                                                 
    5     5        INIT_FCALL                                               'define'
          6        FETCH_CONSTANT                                   ~7      'ERROR'
          7        SEND_VAL                                                 ~7
          8        SEND_VAL                                                 512
          9        DO_ICALL                                                 
    6    10        INIT_FCALL                                               'define'
         11        FETCH_CONSTANT                                   ~9      'WARNING'
         12        SEND_VAL                                                 ~9
         13        SEND_VAL                                                 1024
         14        DO_ICALL                                                 
    9    15        INIT_FCALL                                               'error_reporting'
         16        FETCH_CONSTANT                                   ~11     'FATAL'
         17        FETCH_CONSTANT                                   ~12     'ERROR'
         18        BW_OR                                            ~13     ~11, ~12
         19        FETCH_CONSTANT                                   ~14     'WARNING'
         20        BW_OR                                            ~15     ~13, ~14
         21        SEND_VAL                                                 ~15
         22        DO_ICALL                                                 
   52    23        INIT_FCALL                                               'set_error_handler'
         24        SEND_VAL                                                 'myErrorHandler'
         25        DO_ICALL                                         $17     
         26        ASSIGN                                                   !0, $17
   55    27        ECHO                                                     'vector+a%0A'
   56    28        ASSIGN                                                   !1, <array>
   57    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                                 
   60    32        ECHO                                                     '----%0Avector+b+-+a+warning+%28b+%3D+log%28PI%29+%2A+a%29%0A'
   61    33        INIT_FCALL                                               'scale_by_log'
         34        SEND_VAR                                                 !1
         35        SEND_VAL                                                 3.14159
         36        DO_FCALL                                      0  $21     
         37        ASSIGN                                                   !2, $21
   62    38        INIT_FCALL                                               'print_r'
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                                 
   65    41        ECHO                                                     '----%0Avector+c+-+an+error%0A'
   66    42        INIT_FCALL                                               'scale_by_log'
         43        SEND_VAL                                                 'not+array'
         44        SEND_VAL                                                 2.3
         45        DO_FCALL                                      0  $24     
         46        ASSIGN                                                   !3, $24
   67    47        INIT_FCALL                                               'var_dump'
         48        SEND_VAR                                                 !3
         49        DO_ICALL                                                 
   70    50        ECHO                                                     '----%0Avector+d+-+fatal+error%0A'
   71    51        INIT_FCALL                                               'scale_by_log'
         52        SEND_VAR                                                 !1
         53        SEND_VAL                                                 -2.5
         54        DO_FCALL                                      0  $27     
         55        ASSIGN                                                   !4, $27
   73    56      > 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 = 27
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 34
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
filename:       /in/YWAMt
function name:  myErrorHandler
number of ops:  49
compiled vars:  !0 = $errno, !1 = $errstr, !2 = $errfile, !3 = $errline
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   14     4        FETCH_CONSTANT                                   ~5      'FATAL'
          5        IS_EQUAL                                                 !0, ~5
          6      > JMPNZ                                                    ~4, ->14
   21     7    >   FETCH_CONSTANT                                   ~6      'ERROR'
          8        IS_EQUAL                                                 !0, ~6
          9      > JMPNZ                                                    ~4, ->27
   24    10    >   FETCH_CONSTANT                                   ~7      'WARNING'
         11        IS_EQUAL                                                 !0, ~7
         12      > JMPNZ                                                    ~4, ->34
         13    > > JMP                                                      ->41
   15    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
   16    20        CONCAT                                           ~12     '++Fatal+error+in+line+', !3
         21        CONCAT                                           ~13     ~12, '+of+file+'
         22        CONCAT                                           ~14     ~13, !2
         23        ECHO                                                     ~14
   17    24        ECHO                                                     '%2C+PHP+8.0.0+%28Linux%29%3Cbr%3E%0A'
   18    25        ECHO                                                     'Aborting...%3Cbr%3E%0A'
   20    26      > JMP                                                      ->48
   22    27    >   ROPE_INIT                                     5  ~16     '%3Cb%3EERROR%3C%2Fb%3E+%5B'
         28        ROPE_ADD                                      1  ~16     ~16, !0
         29        ROPE_ADD                                      2  ~16     ~16, '%5D+'
         30        ROPE_ADD                                      3  ~16     ~16, !1
         31        ROPE_END                                      4  ~15     ~16, '%3Cbr%3E%0A'
         32        ECHO                                                     ~15
   23    33      > JMP                                                      ->48
   25    34    >   ROPE_INIT                                     5  ~20     '%3Cb%3EWARNING%3C%2Fb%3E+%5B'
         35        ROPE_ADD                                      1  ~20     ~20, !0
         36        ROPE_ADD                                      2  ~20     ~20, '%5D+'
         37        ROPE_ADD                                      3  ~20     ~20, !1
         38        ROPE_END                                      4  ~19     ~20, '%3Cbr%3E%0A'
         39        ECHO                                                     ~19
   26    40      > JMP                                                      ->48
   28    41    >   ROPE_INIT                                     5  ~24     'Unkown+error+type%3A+%5B'
         42        ROPE_ADD                                      1  ~24     ~24, !0
         43        ROPE_ADD                                      2  ~24     ~24, '%5D+'
         44        ROPE_ADD                                      3  ~24     ~24, !1
         45        ROPE_END                                      4  ~23     ~24, '%3Cbr%3E%0A'
         46        ECHO                                                     ~23
   29    47      > JMP                                                      ->48
   31    48    > > 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/YWAMt
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
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   35     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
   36    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
   37    14        FETCH_CONSTANT                                   ~8      'FATAL'
         15        SEND_VAL                                                 ~8
         16        DO_ICALL                                                 
   38    17    >   TYPE_CHECK                                  128  ~10     !0
         18        BOOL_NOT                                         ~11     ~10
         19      > JMPZ                                                     ~11, ->26
   39    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                                                 
   40    25      > RETURN                                                   null
   42    26    >   ASSIGN                                                   !2, 0
         27      > JMP                                                      ->50
   43    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
   44    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
   45    39        FETCH_CONSTANT                                   ~21     'WARNING'
         40        SEND_VAL                                                 ~21
         41        DO_ICALL                                                 
   46    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
   42    49        PRE_INC                                                  !2
         50    >   COUNT                                            ~28     !0
         51        IS_SMALLER                                               !2, ~28
         52      > JMPNZ                                                    ~29, ->28
   48    53    > > RETURN                                                   !3
   49    54*     > RETURN                                                   null

End of function scale_by_log

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.62 ms | 1414 KiB | 32 Q