3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Erstellt für 01art Webdesign * Datei: mail.php * Beschreibung: E-Mail-Klasse * * Autor: Ernesto Giménez <e@01art.de> * Contributors: * Datum: 28.03.13 12:42 * Letzte Änderung: 02.05.2013 */ class eMail { private $filterdomain, $name, $text, $recipient; public function __construct() { $this->custom_input = ""; } public function setDomain($domain) { $this->filterdomain = $domain; } public function setName($name) { $this->name = $this->spamproof($name); $this->name = $this->charakterproof($this->name); } public function setSiteName($sitename) { $this->sitename = addslashes($sitename); } public function setText($text) { $this->text = $this->spamproof($text); } public function setKopf($kopf) { $this->kopf = $kopf; } public function setRecipient($recipient) { $this->recipient = $this->spamproof($recipient); } public function setRedirect($redirect) { $this->redirect = $redirect; } public function ehost() { return gethostbyaddr($_SERVER["REMOTE_ADDR"]); } public function evaluate($email) { if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { return "nonvalid-email"; } $email = $this->charakterproof($email); return $this->spamproof($email); } public function recode_charset($string,$cs_from,$cs_to) { // Umcodierung $trans_tbl["ASCII"] = array("&", "¡", "€", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "é", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ"); $trans_tbl["UNICODE"] = array("&#x26;", "&#161;", "&#8364;", "&#162;", "&#163;", "&#164;", "&#165;", "&#166;", "&#167;", "&#168;", "&#169;", "&#170;", "&#171;", "&#172;", "&#173;", "&#174;", "&#175;", "&#176;", "&#177;", "&#178;", "&#179;", "&#180;", "&#181;", "&#182;", "&#183;", "&#184;", "&#185;", "&#186;", "&#187;", "&#188;", "&#189;", "&#190;", "&#191;", "&#192;", "&#193;", "&#194;", "&#195;", "&#196;", "&#197;", "&#198;", "&#199;", "&#200;", "&#201;", "&#202;", "&#203;", "&#204;", "&#205;", "&#206;", "&#207;", "&#208;", "&#209;", "&#210;", "&#211;", "&#212;", "&#213;", "&#214;", "&#215;", "&#216;", "&#217;", "&#218;", "&#219;", "&#220;", "&#221;", "&#222;", "&#223;", "&#224;", "&#225;", "&#226;", "&#227;", "&#228;", "&#229;", "&#230;", "&#231;", "&#232;", "&#233;", "&#234;", "&#235;", "&#236;", "&#237;", "&#238;", "&#239;", "&#240;", "&#241;", "&#242;", "&#243;", "&#244;", "&#245;", "&#246;", "&#247;", "&#248;", "&#249;", "&#250;", "&#251;", "&#252;", "&#253;", "&#254;", "&#255;"); $trans_tbl["HTML"] = array("&amp;", "&iexcl;", "&euro;", "&cent;", "&pound;", "&curren;", "&yen;", "&brvbar;", "&sect;", "&uml;", "&copy;", "&ordf;", "&laquo;", "&not;", "&shy;", "&reg;", "&macr;", "&deg;", "&plusmn;", "&sup2;", "&sup3;", "&acute;", "&micro;", "&para;", "&middot;", "&cedil;", "&sup1;", "&ordm;", "&raquo;", "&frac14;", "&frac12;", "&frac34;", "&iquest;", "&Agrave;", "&Aacute;", "&Acirc;", "&Atilde;", "&Auml;", "&Aring;", "&AElig;", "&Ccedil;", "&Egrave;", "&Eacute;", "&Ecirc;", "&Euml;", "&Igrave;", "&Iacute;", "&Icirc;", "&Iuml;", "&ETH;", "&Ntilde;", "&Ograve;", "&Oacute;", "&Ocirc;", "&Otilde;", "&Ouml;", "&times;", "&Oslash;", "&Ugrave;", "&Uacute;", "&Ucirc;", "&Uuml;", "&Yacute;", "&THORN;", "&szlig;", "&agrave;", "&aacute;", "&acirc;", "&atilde;", "&auml;", "&aring;", "&aelig;", "&ccedil;", "&egrave;", "&eacute;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&icirc;", "&iuml;", "&eth;", "&ntilde;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;", "&divide;", "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&yacute;", "&thorn;", "&yuml;"); return str_replace($trans_tbl[$cs_from], $trans_tbl[$cs_to], $string); } public function define_sonderzeichen() { $sonderzeichen=array( "ö" => "ö", "ü" => "ü", "ß" => "ß","ä" => "ä", "Ä" => "Ä", "Ãœ" => "Ü", "Ö" => "Ö", "é" => "é", "è" => "é", "ê" => "ê", "á" => "á", "²" => "²", "°" => "°", "ñ" => "ñ", "Ã'" => "Ñ", "à " => "à", "ô" => "ô", "€" => "€", "'" => "\"", "„" => "\"", "‘" => "\"", "’" => "'", "Â" => " "); return $sonderzeichen; } private function spamproof($objekt) { // old proof /* if ((preg_match("/@".$this->filterdomain."/i", $email)) || (preg_match("/@aol.com/i", $this->name)) || (preg_match("/@/i", $this->name)) || (preg_match("/url=http/i", $this->text)) || (preg_match("/Content-Type:/i", $this->text)) || (preg_match("/bcc:/i", $email)) || (preg_match("/Content-Type:/i", $this->text)) || (preg_match("/bcc:/i", $this->text)) ) { header ("Location: http://".$this->filterdomain."/"); exit(); } return $email; */ if ( preg_match("/(to:|cc:|bcc:|from:|subject:|reply-to:|content-type:|MIME-Version:|multipart\/mixed|Content-Transfer-Encoding:)/ims", $objekt)) { header("Location: http://".$this->filterdomain."/"); exit(); } return $objekt; } private function charakterproof($objekt) { if (preg_match("/%0A|%0D|%00|\\0|%09|%01|%02|%03|%04|%05|%06|%07|%08|%09|%0B|%0C|%0E|%0F|%10|%11|%12|%13/i", $objekt)) { header("Location: http://".$this->filterdomain."/"); exit(); } return $objekt; } public function edate() { $hourdiff = "0"; // hours difference between server time and local time $timeadjust = ($hourdiff * 60 * 60); return date("d F Y, G:i:s",time() + $timeadjust); } private function eheader($email) { $header = "MIME-Version: 1.0\r\n"; $header .= "Content-Type: text/plain; charset=UTF-8\r\n"; $header .= "Content-Transfer-Encoding: 8bit\r\n"; $header .= "From: \"$this->name\"<$email>\r\n"; //$header .= "bcc: $recipient\r\n"; $header .= "Return-path: $this->recipient\r\n"; $header .= "X-Mailer: 01art Webdesign Internet-Mailer \r\n"; return $header; } private function email_send_template($email) { mail( $this->recipient, $this->sitename." E-Mail-Form", email_content($email). //"=======================================================\n". $this->kopf . //"\n=======================================================\n" . PHP_EOL . //"Date of entry : " . $this->edate() . " o'clock \nMr/Mrs " . $this->name . //" has given the following information: " . PHP_EOL . //"\n____________________________________________________________\n\n" . PHP_EOL . //"CONTACT\n" . PHP_EOL . //"Name: " . $this->name . //"\nEmail: ". $email . $this->custom_input . //"\n____________________________________________________________\n\n" . PHP_EOL . //"Message: \n" . $this->text . //"\n____________________________________________________________\n" . PHP_EOL . //"____________________________________________________________\n" . PHP_EOL . //"Browser and operating system of the sender : " . $_SERVER['HTTP_USER_AGENT'] . //"\nIP of the sender : ".$_SERVER['REMOTE_ADDR']." \nRemote Host of the sender : " . $this->ehost(), $this->eheader($email) ); return; } private static function email_content($email){ $mainContent = "=======================================================\n".$this->kopf. "\n=======================================================\n" . PHP_EOL . "Date of entry : " . $this->edate() . " o'clock \nMr/Mrs " . $this->name . " has given the following information: " . PHP_EOL . "\n____________________________________________________________\n\n" . PHP_EOL . "CONTACT\n" . PHP_EOL . "Name: " . $this->name . "\nEmail: ". $email . $this->custom_input . "\n____________________________________________________________\n\n" . PHP_EOL . "Message: \n" . $this->text . "\n____________________________________________________________\n" . PHP_EOL . "____________________________________________________________\n" . PHP_EOL . "Browser and operating system of the sender : " . $_SERVER['HTTP_USER_AGENT'] . "\nIP of the sender : ".$_SERVER['REMOTE_ADDR']." \nRemote Host of the sender : " . ";" echo $mainContent; } public static function fillContent(){ return $mainContent; } public function send_mail($from) { if (isset($from)) { $email = $this->evaluate($from); } if (isset($this->name, $email) && ($email != "nonvalid-email") ){ $this->email_send_template($email); header("Location: ".$this->redirect); } else {exit(); } } }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.270.0090.04212.52
5.4.260.0060.04412.52
5.4.250.0100.04012.52
5.4.240.0070.04312.52
5.4.230.0070.04512.51
5.4.220.0060.04312.51
5.4.210.0050.04312.51
5.4.200.0050.04212.51
5.4.190.0080.04312.51
5.4.180.0070.03812.51
5.4.170.0040.04112.52
5.4.160.0070.04512.51
5.4.150.0070.04412.51
5.4.140.0060.04112.20
5.4.130.0060.03812.18
5.4.120.0060.04412.14
5.4.110.0070.04912.14
5.4.100.0090.04612.14
5.4.90.0060.04812.14
5.4.80.0070.04712.14
5.4.70.0060.04412.14
5.4.60.0050.03512.13
5.4.50.0030.04012.14
5.4.40.0040.03612.12
5.4.30.0070.03512.12
5.4.20.0070.03512.12
5.4.10.0060.03512.12
5.4.00.0080.03811.61
5.3.280.0080.04312.76
5.3.270.0070.04812.78
5.3.260.0080.04112.78
5.3.250.0050.04112.78
5.3.240.0060.04012.78
5.3.230.0080.03812.77
5.3.220.0100.03812.74
5.3.210.0060.04112.74
5.3.200.0090.03512.74
5.3.190.0070.03812.74
5.3.180.0070.03812.74
5.3.170.0070.03812.74
5.3.160.0050.04112.74
5.3.150.0050.04512.73
5.3.140.0070.03912.73
5.3.130.0100.03912.72
5.3.120.0040.04712.72
5.3.110.0090.04512.72
5.3.100.0110.03812.21
5.3.90.0060.04212.19
5.3.80.0070.03812.17
5.3.70.0070.03812.17
5.3.60.0080.03612.16
5.3.50.0040.03912.10
5.3.40.0050.04712.11
5.3.30.0090.04512.07
5.3.20.0080.03611.85
5.3.10.0070.03911.81
5.3.00.0070.03811.80

preferences:
138.94 ms | 1394 KiB | 7 Q