3v4l.org

run code in 300+ PHP versions simultaneously
<?php include 'Mailer.php'; include 'Validator.php'; define("PREIS_PRO_250G", 6.20); define("PREIS_PRO_500G", 10.50); define("PORTO", 5.50); function calculateTotalPrice($menge250g, $menge500g) { $totalPrice = (PREIS_PRO_250G * $menge250g) + (PREIS_PRO_500G * $menge500g) + PORTO; $totalPrice = sprintf("%.2f", $totalPrice); return $totalPrice; } function createOKMessage($totalPrice){ $msg = '<span style="color:green"><br />Vielen Dank für Ihre Bestellung, wir werden Sie sofort nach Geldeingang bearbeiten!<br />Bitte überweisen Sie den Betrag von '; $msg .= $totalPrice; $msg .= ' EURO auf das in der E-Mail angegebene Konto.<br />'; return $msg; } function createCalcMessage($totalPrice){ $msg = '<span style="color:green"><br />Ihre aktuelle Bestellung würde '; $msg .= $totalPrice; $msg .= ' EURO kosten.<br />'; return $msg; } $name = trim(strip_tags($_POST['name'])); $email = trim(strip_tags($_POST['email'])); $strasse = trim(strip_tags($_POST['strasse'])); $plz = trim(strip_tags($_POST['plz'])); $stadt = trim(strip_tags($_POST['stadt'])); $menge250g = trim(strip_tags($_POST['menge250g'])); $menge500g = trim(strip_tags($_POST['menge500g'])); if (!isset($menge250g) or $menge250g == ""){ $menge250g = 0; } if (!isset($menge500g) or $menge500g == ""){ $menge500g = 0; } $message = NULL; $validator = new Validator(); if(isset($_POST['submit'])){ // Eingabe validieren $valid = $validator->validateInput($name, $email, $strasse, $plz, $stadt, $menge250g, $menge500g); if($valid){ // Konnte die Eingabe erfolgreich validiert werden, wird der entdgueltige Preis berechnet und // die Email an den Kunden versendet $totalPrice = calculateTotalPrice($menge250g, $menge500g); Mailer::sendToCustomer($name, $email, $strasse, $plz, $stadt, $menge250g, $menge500g, $totalPrice); $message = createOKMessage($totalPrice); $name = ""; $email = ""; $strasse = ""; $plz = ""; $stadt = ""; $menge250g = 0; $menge500g = 0; } else{ // Im Fehlerfall werden die Fehlermeldungen ausgegeben $message = $validator->getErrorMessages(); } } if(isset($_POST['calc'])){ $totalPrice = calculateTotalPrice($menge250g, $menge500g); $message = createCalcMessage($totalPrice); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; } .Stil3 { font-size: 10px } body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .Stil4 { color: #000000; background-image: none; background-position: left top; } --> </style> </head> <body style="background-color: transparent;"> <form name="Bestellformular" action="<? echo $_SERVER['file:///PHP_SELF']; ?>" method="post"> <table width="380" align="left"> <tr> <td width="160"><strong>Ihr Name:</strong></td> <td width="208"><input name="name" type="text" value="<? echo $name; ?>" size="26" maxlength="100" /></td> </tr> <tr> <td width="160"><strong>E-Mail:</strong><br /> </td> <td><input name="email" type="text" id="email" value="<? echo $email; ?>" size="26" maxlength="100" /></td> </tr> <tr> <td width="160">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td width="160"><strong>Lieferanschrift</strong><br /> </td> <td>&nbsp;</td> </tr> <tr> <td width="160"><strong>Strasse / Hausnummer</strong><br /> </td> <td><input name="strasse" type="text" id="strasse" value="<? echo $strasse; ?>" size="26" maxlength="100" /></td> </tr> <tr> <td width="160"><strong>Postleitzahl</strong><br /> </td> <td><input name="plz" type="text" id="plz" value="<? echo $plz; ?>" size="26" maxlength="5" /></td> </tr> <tr> <td width="160"><strong>Stadt</strong><br /> </td> <td><input name="stadt" type="text" id="stadt" value="<? echo $stadt; ?>" size="26" maxlength="100" /></td> </tr> <tr> <td width="160">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td><strong>Päckchen</strong><br /> </td> <td>&nbsp;</td> </tr> <tr> <td><strong>Menge a 250g zu je 6,20€:</strong><br /> </td> <td><input name="menge250g" type="text" id="menge250g" value="<? echo $menge250g; ?>" size="26" maxlength="1" /></td> </tr> <tr> <td><strong>Menge a 500g zu je 10,50€:</strong><br /> </td> <td><input name="menge500g" type="text" id="menge500g" value="<? echo $menge500g; ?>" size="26" maxlength="1" /></td> </tr> <tr> <td width="160">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td width="160"><strong>Versandpauschale 5,50€</strong></td> <td>&nbsp;</td> </tr> <tr> <td width="160">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td colspan="2"><?echo $message;?></td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" value="Abschicken" name="submit" /></td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" value="Berechnen" name="calc" /></td> </tr> </table> </form> </body> </html>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: include(): open_basedir restriction in effect. File(Mailer.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/6LFsg on line 2 Warning: include(Mailer.php): Failed to open stream: Operation not permitted in /in/6LFsg on line 2 Warning: include(): Failed opening 'Mailer.php' for inclusion (include_path='.:') in /in/6LFsg on line 2 Warning: include(): open_basedir restriction in effect. File(Validator.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/6LFsg on line 3 Warning: include(Validator.php): Failed to open stream: Operation not permitted in /in/6LFsg on line 3 Warning: include(): Failed opening 'Validator.php' for inclusion (include_path='.:') in /in/6LFsg on line 3 Warning: Undefined array key "name" in /in/6LFsg on line 32 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /in/6LFsg on line 32 Warning: Undefined array key "email" in /in/6LFsg on line 33 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /in/6LFsg on line 33 Warning: Undefined array key "strasse" in /in/6LFsg on line 34 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /in/6LFsg on line 34 Warning: Undefined array key "plz" in /in/6LFsg on line 35 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /in/6LFsg on line 35 Warning: Undefined array key "stadt" in /in/6LFsg on line 36 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /in/6LFsg on line 36 Warning: Undefined array key "menge250g" in /in/6LFsg on line 37 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /in/6LFsg on line 37 Warning: Undefined array key "menge500g" in /in/6LFsg on line 38 Deprecated: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /in/6LFsg on line 38 Fatal error: Uncaught Error: Class "Validator" not found in /in/6LFsg:49 Stack trace: #0 {main} thrown in /in/6LFsg on line 49
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
19.18 ms | 403 KiB | 8 Q