3v4l.org

run code in 300+ PHP versions simultaneously
<?php define("ERROR_INVALID_NAME", "Ung&uuml;ltiger Name"); define("ERROR_INVALID_EMAIL_ADDRESS", "Ung&uuml;ltiges E-Mailformat"); define("ERROR_INVALID_STREET", "Ung&uuml;ltiger Strassenname"); define("ERROR_INVALID_POSTALCODE", "Ung&uuml;ltige Postleitzahl! Bitte nur Zahlen eingeben"); define("ERROR_INVALID_CITY", "Ung&uuml;ltige Stadt"); define("ERROR_INVALID_AMOUNT250", "Ung&uuml;ltige Menge bei 250g"); define("ERROR_INVALID_AMOUNT500", "Ung&uuml;ltige Menge bei 500g"); define("ERROR_INVALID_AMOUNT", "Die Gesamtmenge betr&auml;gt 0"); define("ERROR_INVALID_PRICE", "Ung&uuml;ltiger Preis"); define("ERROR_INVALID_DATUM", "Ung&uuml;ltiges Datum"); /** * Validator fuer die Eingabe des Kunden */ class Validator{ var $errorMessages; /** * Validiert die Eingabe. */ function validateInput($name, $email, $strasse, $plz, $stadt, $menge250g, $menge500g){ $this->validate($name, $email, $strasse, $plz, $stadt, $menge250g, $menge500g); return $this->isValid(); } /** * Validiert die Confirmation. */ function validateConfirmation($name, $email, $strasse, $plz, $stadt, $menge250g, $menge500g, $preis, $datum){ $this->validate($name, $email, $strasse, $plz, $stadt, $menge250g, $menge500g); // Menge gefuellt und numersich if($preis == ''){ array_push($this->errorMessages, ERROR_INVALID_PREIS); } // Menge gefuellt und numersich if($datum == ''){ array_push($this->errorMessages, ERROR_INVALID_DATUM); } return $this->isValid(); } /** * Validiert die Bestaetigungsparameter. */ function validate($name, $email, $strasse, $plz, $stadt, $menge250g, $menge500g){ $this->errorMessages = array(); // Name gefuellt if($name == ""){ array_push($this->errorMessages, ERROR_INVALID_NAME); } // Email Adresse korrekt if(!ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$", $email)){ array_push($this->errorMessages, ERROR_INVALID_EMAIL_ADDRESS); } // Strasse gefuellt if($strasse == ""){ array_push($this->errorMessages, ERROR_INVALID_STREET); } // PLZ gefuellt und numerisch if(!ereg("^[0-9-]", $plz)){ array_push($this->errorMessages, ERROR_INVALID_POSTALCODE); } // Stadt gefuellt if($stadt == ""){ array_push($this->errorMessages, ERROR_INVALID_CITY); } // Menge250g gefuellt und numersich if(!ereg("^[0-9-]", $menge250g)){ array_push($this->errorMessages, ERROR_INVALID_AMOUNT250); } // Menge500g gefuellt und numersich if(!ereg("^[0-9-]", $menge500g)){ array_push($this->errorMessages, ERROR_INVALID_AMOUNT500); } if ($menge250g == 0.0 and $menge500g == 0.0){ array_push($this->errorMessages, ERROR_INVALID_AMOUNT); } return $this->isValid(); } /** * Erzeugt eine Message fuer die letzte Validierung, */ function getErrorMessages(){ $msg = "<span style='color:red'>Fehler, Sie haben nicht alle Felder korrekt ausgef&uuml;llt:"; // Erzeugte Fehlermeldungen einsammeln foreach ($this->errorMessages as $value) { $msg .= "<br /> - " . $value; } $msg .= "</span><br /><br />"; unset($value); return $msg; } /** * Ueberprueft, ob Fehler bei der Validierung aufgetreten sind. */ function isValid(){ if (count($this->errorMessages) == 0){ return true; } return false; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g5dbe
function name:  (null)
number of ops:  41
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'ERROR_INVALID_NAME'
          2        SEND_VAL                                                 'Ung%26uuml%3Bltiger+Name'
          3        DO_ICALL                                                 
    3     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'ERROR_INVALID_EMAIL_ADDRESS'
          6        SEND_VAL                                                 'Ung%26uuml%3Bltiges+E-Mailformat'
          7        DO_ICALL                                                 
    4     8        INIT_FCALL                                               'define'
          9        SEND_VAL                                                 'ERROR_INVALID_STREET'
         10        SEND_VAL                                                 'Ung%26uuml%3Bltiger+Strassenname'
         11        DO_ICALL                                                 
    5    12        INIT_FCALL                                               'define'
         13        SEND_VAL                                                 'ERROR_INVALID_POSTALCODE'
         14        SEND_VAL                                                 'Ung%26uuml%3Bltige+Postleitzahl%21+Bitte+nur+Zahlen+eingeben'
         15        DO_ICALL                                                 
    6    16        INIT_FCALL                                               'define'
         17        SEND_VAL                                                 'ERROR_INVALID_CITY'
         18        SEND_VAL                                                 'Ung%26uuml%3Bltige+Stadt'
         19        DO_ICALL                                                 
    7    20        INIT_FCALL                                               'define'
         21        SEND_VAL                                                 'ERROR_INVALID_AMOUNT250'
         22        SEND_VAL                                                 'Ung%26uuml%3Bltige+Menge+bei+250g'
         23        DO_ICALL                                                 
    8    24        INIT_FCALL                                               'define'
         25        SEND_VAL                                                 'ERROR_INVALID_AMOUNT500'
         26        SEND_VAL                                                 'Ung%26uuml%3Bltige+Menge+bei+500g'
         27        DO_ICALL                                                 
    9    28        INIT_FCALL                                               'define'
         29        SEND_VAL                                                 'ERROR_INVALID_AMOUNT'
         30        SEND_VAL                                                 'Die+Gesamtmenge+betr%26auml%3Bgt+0'
         31        DO_ICALL                                                 
   10    32        INIT_FCALL                                               'define'
         33        SEND_VAL                                                 'ERROR_INVALID_PRICE'
         34        SEND_VAL                                                 'Ung%26uuml%3Bltiger+Preis'
         35        DO_ICALL                                                 
   11    36        INIT_FCALL                                               'define'
         37        SEND_VAL                                                 'ERROR_INVALID_DATUM'
         38        SEND_VAL                                                 'Ung%26uuml%3Bltiges+Datum'
         39        DO_ICALL                                                 
  122    40      > RETURN                                                   1

Class Validator:
Function validateinput:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g5dbe
function name:  validateInput
number of ops:  20
compiled vars:  !0 = $name, !1 = $email, !2 = $strasse, !3 = $plz, !4 = $stadt, !5 = $menge250g, !6 = $menge500g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
          6        RECV                                             !6      
   24     7        INIT_METHOD_CALL                                         'validate'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAR_EX                                              !1
         10        SEND_VAR_EX                                              !2
         11        SEND_VAR_EX                                              !3
         12        SEND_VAR_EX                                              !4
         13        SEND_VAR_EX                                              !5
         14        SEND_VAR_EX                                              !6
         15        DO_FCALL                                      0          
   26    16        INIT_METHOD_CALL                                         'isValid'
         17        DO_FCALL                                      0  $8      
         18      > RETURN                                                   $8
   27    19*     > RETURN                                                   null

End of function validateinput

Function validateconfirmation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 26
filename:       /in/g5dbe
function name:  validateConfirmation
number of ops:  38
compiled vars:  !0 = $name, !1 = $email, !2 = $strasse, !3 = $plz, !4 = $stadt, !5 = $menge250g, !6 = $menge500g, !7 = $preis, !8 = $datum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
          6        RECV                                             !6      
          7        RECV                                             !7      
          8        RECV                                             !8      
   33     9        INIT_METHOD_CALL                                         'validate'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAR_EX                                              !1
         12        SEND_VAR_EX                                              !2
         13        SEND_VAR_EX                                              !3
         14        SEND_VAR_EX                                              !4
         15        SEND_VAR_EX                                              !5
         16        SEND_VAR_EX                                              !6
         17        DO_FCALL                                      0          
   36    18        IS_EQUAL                                                 !7, ''
         19      > JMPZ                                                     ~10, ->26
   37    20    >   INIT_FCALL                                               'array_push'
         21        FETCH_OBJ_W                                      $11     'errorMessages'
         22        SEND_REF                                                 $11
         23        FETCH_CONSTANT                                   ~12     'ERROR_INVALID_PREIS'
         24        SEND_VAL                                                 ~12
         25        DO_ICALL                                                 
   41    26    >   IS_EQUAL                                                 !8, ''
         27      > JMPZ                                                     ~14, ->34
   42    28    >   INIT_FCALL                                               'array_push'
         29        FETCH_OBJ_W                                      $15     'errorMessages'
         30        SEND_REF                                                 $15
         31        FETCH_CONSTANT                                   ~16     'ERROR_INVALID_DATUM'
         32        SEND_VAL                                                 ~16
         33        DO_ICALL                                                 
   45    34    >   INIT_METHOD_CALL                                         'isValid'
         35        DO_FCALL                                      0  $18     
         36      > RETURN                                                   $18
   46    37*     > RETURN                                                   null

End of function validateconfirmation

Function validate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 49
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 57
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 69
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 81
Branch analysis from position: 75
2 jumps found. (Code = 46) Position 1 = 83, Position 2 = 85
Branch analysis from position: 83
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 92
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 92
Branch analysis from position: 85
Branch analysis from position: 81
Branch analysis from position: 69
Branch analysis from position: 57
Branch analysis from position: 49
Branch analysis from position: 37
Branch analysis from position: 29
Branch analysis from position: 17
filename:       /in/g5dbe
function name:  validate
number of ops:  96
compiled vars:  !0 = $name, !1 = $email, !2 = $strasse, !3 = $plz, !4 = $stadt, !5 = $menge250g, !6 = $menge500g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
          6        RECV                                             !6      
   52     7        ASSIGN_OBJ                                               'errorMessages'
          8        OP_DATA                                                  <array>
   55     9        IS_EQUAL                                                 !0, ''
         10      > JMPZ                                                     ~8, ->17
   56    11    >   INIT_FCALL                                               'array_push'
         12        FETCH_OBJ_W                                      $9      'errorMessages'
         13        SEND_REF                                                 $9
         14        FETCH_CONSTANT                                   ~10     'ERROR_INVALID_NAME'
         15        SEND_VAL                                                 ~10
         16        DO_ICALL                                                 
   60    17    >   INIT_FCALL_BY_NAME                                       'ereg'
         18        SEND_VAL_EX                                              '%5E%5B_a-zA-Z0-9-%5D%2B%28%5C.%5B_a-zA-Z0-9-%5D%2B%29%2A%40%28%5Ba-zA-Z0-9-%5D%2B%5C.%29%2B%28%5Ba-zA-Z%5D%7B2%2C4%7D%29%24'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0  $12     
         21        BOOL_NOT                                         ~13     $12
         22      > JMPZ                                                     ~13, ->29
   61    23    >   INIT_FCALL                                               'array_push'
         24        FETCH_OBJ_W                                      $14     'errorMessages'
         25        SEND_REF                                                 $14
         26        FETCH_CONSTANT                                   ~15     'ERROR_INVALID_EMAIL_ADDRESS'
         27        SEND_VAL                                                 ~15
         28        DO_ICALL                                                 
   65    29    >   IS_EQUAL                                                 !2, ''
         30      > JMPZ                                                     ~17, ->37
   66    31    >   INIT_FCALL                                               'array_push'
         32        FETCH_OBJ_W                                      $18     'errorMessages'
         33        SEND_REF                                                 $18
         34        FETCH_CONSTANT                                   ~19     'ERROR_INVALID_STREET'
         35        SEND_VAL                                                 ~19
         36        DO_ICALL                                                 
   70    37    >   INIT_FCALL_BY_NAME                                       'ereg'
         38        SEND_VAL_EX                                              '%5E%5B0-9-%5D'
         39        SEND_VAR_EX                                              !3
         40        DO_FCALL                                      0  $21     
         41        BOOL_NOT                                         ~22     $21
         42      > JMPZ                                                     ~22, ->49
   71    43    >   INIT_FCALL                                               'array_push'
         44        FETCH_OBJ_W                                      $23     'errorMessages'
         45        SEND_REF                                                 $23
         46        FETCH_CONSTANT                                   ~24     'ERROR_INVALID_POSTALCODE'
         47        SEND_VAL                                                 ~24
         48        DO_ICALL                                                 
   75    49    >   IS_EQUAL                                                 !4, ''
         50      > JMPZ                                                     ~26, ->57
   76    51    >   INIT_FCALL                                               'array_push'
         52        FETCH_OBJ_W                                      $27     'errorMessages'
         53        SEND_REF                                                 $27
         54        FETCH_CONSTANT                                   ~28     'ERROR_INVALID_CITY'
         55        SEND_VAL                                                 ~28
         56        DO_ICALL                                                 
   80    57    >   INIT_FCALL_BY_NAME                                       'ereg'
         58        SEND_VAL_EX                                              '%5E%5B0-9-%5D'
         59        SEND_VAR_EX                                              !5
         60        DO_FCALL                                      0  $30     
         61        BOOL_NOT                                         ~31     $30
         62      > JMPZ                                                     ~31, ->69
   81    63    >   INIT_FCALL                                               'array_push'
         64        FETCH_OBJ_W                                      $32     'errorMessages'
         65        SEND_REF                                                 $32
         66        FETCH_CONSTANT                                   ~33     'ERROR_INVALID_AMOUNT250'
         67        SEND_VAL                                                 ~33
         68        DO_ICALL                                                 
   85    69    >   INIT_FCALL_BY_NAME                                       'ereg'
         70        SEND_VAL_EX                                              '%5E%5B0-9-%5D'
         71        SEND_VAR_EX                                              !6
         72        DO_FCALL                                      0  $35     
         73        BOOL_NOT                                         ~36     $35
         74      > JMPZ                                                     ~36, ->81
   86    75    >   INIT_FCALL                                               'array_push'
         76        FETCH_OBJ_W                                      $37     'errorMessages'
         77        SEND_REF                                                 $37
         78        FETCH_CONSTANT                                   ~38     'ERROR_INVALID_AMOUNT500'
         79        SEND_VAL                                                 ~38
         80        DO_ICALL                                                 
   89    81    >   IS_EQUAL                                         ~40     !5, 0
         82      > JMPZ_EX                                          ~40     ~40, ->85
         83    >   IS_EQUAL                                         ~41     !6, 0
         84        BOOL                                             ~40     ~41
         85    > > JMPZ                                                     ~40, ->92
   90    86    >   INIT_FCALL                                               'array_push'
         87        FETCH_OBJ_W                                      $42     'errorMessages'
         88        SEND_REF                                                 $42
         89        FETCH_CONSTANT                                   ~43     'ERROR_INVALID_AMOUNT'
         90        SEND_VAL                                                 ~43
         91        DO_ICALL                                                 
   93    92    >   INIT_METHOD_CALL                                         'isValid'
         93        DO_FCALL                                      0  $45     
         94      > RETURN                                                   $45
   94    95*     > RETURN                                                   null

End of function validate

Function geterrormessages:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/g5dbe
function name:  getErrorMessages
number of ops:  12
compiled vars:  !0 = $msg, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  100     0  E >   ASSIGN                                                   !0, '%3Cspan+style%3D%27color%3Ared%27%3EFehler%2C+Sie+haben+nicht+alle+Felder+korrekt+ausgef%26uuml%3Bllt%3A'
  102     1        FETCH_OBJ_R                                      ~3      'errorMessages'
          2      > FE_RESET_R                                       $4      ~3, ->7
          3    > > FE_FETCH_R                                               $4, !1, ->7
  103     4    >   CONCAT                                           ~5      '%3Cbr+%2F%3E+-+', !1
          5        ASSIGN_OP                                     8          !0, ~5
  102     6      > JMP                                                      ->3
          7    >   FE_FREE                                                  $4
  105     8        ASSIGN_OP                                     8          !0, '%3C%2Fspan%3E%3Cbr+%2F%3E%3Cbr+%2F%3E'
  106     9        UNSET_CV                                                 !1
  108    10      > RETURN                                                   !0
  109    11*     > RETURN                                                   null

End of function geterrormessages

Function isvalid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g5dbe
function name:  isValid
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  115     0  E >   FETCH_OBJ_R                                      ~0      'errorMessages'
          1        COUNT                                            ~1      ~0
          2        IS_EQUAL                                                 ~1, 0
          3      > JMPZ                                                     ~2, ->5
  116     4    > > RETURN                                                   <true>
  119     5    > > RETURN                                                   <false>
  120     6*     > RETURN                                                   null

End of function isvalid

End of class Validator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.76 ms | 1408 KiB | 17 Q