3v4l.org

run code in 300+ PHP versions simultaneously
<?php use Nette\Application\UI\Form; use Nette\Utils\Strings; final class PagePresenter extends BasePresenter { public function startup() { parent::startup(); } public function beforeRender() { parent::beforeRender(); } // AJAX public function handleAjax() { $this->template->prom = 'Hodnota poslaná AJAXem.'; $this->redrawControl();//překreslíme komponentu } public function renderAjax() { //tato metoda se provádí vždy, proto musíme zamezit přepsání hodnoty z handle if (! $this->isAjax()) { $this->template->prom = 'Výchozí hodnota.'; } } // HOMEPAGE public function actionHome($id) { $this->template->nette = \Nette\Framework::NAME.' '.\Nette\Framework::VERSION.' ('.\Nette\Framework::REVISION.')'; } // SLEEP COUNTER protected function createComponentTimeCountDownForm() { $form = new Form; $form->addText('sleepHours', NULL) ->setType('number') ->setDefaultValue(date('G')) ->addRule(Form::RANGE, 'Povolené hodnoty jsou 0 až 23', array(0, 23)); $form->addText('sleepMinutes', NULL) ->setType('number') ->setDefaultValue(date('i')) ->addRule(Form::RANGE, 'Povolené hodnoty jsou 0 až 23', array(0, 60)); $form->addText('getupHours', NULL) ->setType('number') ->setType('number') ->addRule(Form::RANGE, 'Povolené hodnoty jsou 0 až 23', array(0, 23)); $form->addText('getupMinutes', NULL) ->setType('number') ->addRule(Form::RANGE, 'Povolené hodnoty jsou 0 až 23', array(0, 60)); $cookie = $this->getHttpRequest()->getCookie('sleepCounter'); if ($cookie) { list($dH, $dM) = explode(';', $cookie); $form->setDefaults(array( 'getupHours' => $dH, 'getupMinutes' => $dM )); } $form->addSubmit('count', 'Vypočítat'); $form->onSuccess[] = callback($this, 'processTimeCountDown'); return $form; } public function processTimeCountDown(Form $form) { $values = $form->getValues(); $add = 0; $start = new Datetime(); $start->setTime($values->sleepHours, $values->sleepMinutes); $end = new Datetime(); $end->setTime($values->getupHours, $values->getupMinutes); if (time() > $end->getTimestamp()) { $end->add(new DateInterval('P'.($add + 1).'D')); } $dd = date_diff($start, $end); $this->getHttpResponse()->setCookie('sleepCounter', "{$values->getupHours};{$values->getupMinutes}", '+ 100 days'); $this->flashMessage("Vstávat budete za " .($dd->h != 0 ? ("{$dd->h} hodin".($dd->h == 1 ? 'u' : ($dd->h <= 4 ? 'y' : ''))).' a ' : '') ."{$dd->i} minut".($dd->i == 1 ? 'u' : ($dd->i <= 4 && $dd->i > 0 ? 'y' : '')) , 'info'); } // NETTE DETECTOR protected function createComponentNetteWebChecker() { $form = new Form; $form->setMethod('GET'); $form->addText('url', 'URL adresa: ') ->addRule(Form::URL, 'URL má špatný tvar'); $form->addText('test', NULL) ->addRule(~Form::FILLED, 'Tento formulář není pro vás..') ->setAttribute('style', 'display: none'); $form->addSubmit('check', 'Zjisti to'); $form->onSuccess[] = callback($this, 'processNetteWebChecker'); return $form; } public function processNetteWebChecker(Form $form) { $url = $form->values->url; if (! preg_match('~http(s)?://~i', $url)) { $url = "http://$url"; } $headers = @get_headers($url, TRUE);//dump($headers); $status = NULL; $poweredBy = ''; if (isset($headers['X-Powered-By'])) { $poweredBy = strval(is_array($headers['X-Powered-By']) ? $headers['X-Powered-By'][0] : $headers['X-Powered-By']); } if (! $headers) { $status = 'error'; $this->flashMessage ('Tento web neexistuje.', 'danger'); } else if (strtolower($poweredBy) == 'nette framework') { $status = 'yes'; $this->flashMessage('Ano, stránka '.$url.' opravdu běží na <strong>Nette Frameworku</strong>!', 'success'); } else { $status = 'no'; $this->flashMessage ('Bohužel, stránka '.$url.' <strong>zatím</strong> Nette Framework nepoužívá.', 'danger'); } $this->db->table('nette_detector')->insert(array( 'nette' => $status, 'url' => $url, 'when' => new \DateTime('now'), 'userAgent' => $_SERVER['HTTP_USER_AGENT'], 'poweredBy' => $poweredBy, 'ip' => $_SERVER['REMOTE_ADDR'], 'hostname' => getHostByAddr($_SERVER['REMOTE_ADDR']) )); } // NETTE DETECTOR RECORDS public function renderDetectorShow() { $this->template->list = $this->db->table('nette_detector') ->order('`when` DESC') ->select('*') ->fetchAll(); } // TEXT ANALYZER protected function createComponentTextForm() { $form = new Form; $form->addTextArea('text', NULL) ->setRequired('Zadejte text k analýze'); $form->addSubmit('analyze', 'Analyzovat'); $form->onSuccess[] = callback($this, 'processTextForm'); return $form; } public function processTextForm(Form $form) { $text = $form->values->text; @file_put_contents('./texts/'.time().'.txt', implode('|||',array( 'ip' => $_SERVER['REMOTE_ADDR'], 'dns' => getHostByAddr($_SERVER['REMOTE_ADDR']), 'userAgent' => $_SERVER['HTTP_USER_AGENT'] ))."\n\n".$text); $splitWords = preg_split('~([;,!\?:/"\(\)])|(\s+)|(\.\s)~', $text); $words = array(); $stat = new Nette\ArrayHash(); $stat->repeatedWords = array(); foreach ($splitWords as & $str) { $str = trim(Strings::lower($str)); if ($str == '' || ! Strings::match($str, '~\p{L}~ui')) { unset($str); continue; } $words[] = $str; $stat->repeatedWords[$str] = array_key_exists($str, $stat->repeatedWords) ? $stat->repeatedWords[$str] + 1 : 1; } $stat->wordCount = count($words); arsort($stat->repeatedWords); $stat->paragraphCount = count(Strings::matchAll($text, '~(\n\n[\s]?)~ism')) + 1; $stat->length = Strings::length($text); $stat->whitespaceCount = mb_substr_count($text, " ", 'UTF-8') + mb_substr_count($text, "\n", 'UTF-8'); $stat->whitespaceCountPercent = 100 / $stat->length * $stat->whitespaceCount; $stat->ns = $stat->length / 1800; $stat->dotCount = mb_substr_count($text, '.', 'UTF-8'); $stat->exclamationMarkCount = mb_substr_count($text, '!', 'UTF-8'); $stat->pointCount = mb_substr_count($text, ',', 'UTF-8'); $stat->interrogationCount = mb_substr_count($text, '?', 'UTF-8'); $stat->semicolonCount = mb_substr_count($text, ';', 'UTF-8'); $stat->hyphenCount = mb_substr_count($text, '-', 'UTF-8'); $this->template->stat = $stat; } // PHP INFO public function renderPhpinfo() { $this->setLayout(FALSE); } public function renderErrorUrlList() { $this->template->errors = $this->db->table('url_error')->order('`when` DESC')->fetchAll(); } // STRING TOOLS protected function createComponentStringToolForm() { $form = new Form; $form->addTextArea('data', 'Data: ') ->setAttribute('class', 'form-control') ->setAttribute('style', 'width: 600px; height: 200px;'); $form->addSelect('func', 'Akce: ', array( 'JSON' => array( 'json_encode' => 'Zakódovat', 'json_decode' => 'Dekódovat' ), 'URL' => array( 'urlencode' => 'Zakódovat', 'urldecode' => 'Dekódovat', 'rawurlencode' => 'Zakódovat RAW', 'rawurldecode' => 'Dekódovat RAW' ), 'BASE 64' => array( 'base64_encode' => 'Zakódovat', 'base64_decode' => 'Dekódovat' ), 'Hashe' => array( 'sha1' => 'SHA1', 'md5' => 'MD5' ))) ->setAttribute('class', 'form-control') ->setAttribute('style', 'width: 150px;'); $form->addSubmit('convert', 'Provést') ->setAttribute('class', 'btn btn-success'); $form->onSuccess[] = $this->processStringToolForm; return $form; } public function processStringToolForm(Form $form) { $func = $form->values->func; $result = $func($form->values->data); if ($result === FALSE || is_null($result)) { $this->flashMessage('Chyba při zpracování, zřejmě vkládáte nevalidní formát', 'danger'); } else { $result = is_array($result) || is_object($result) ? var_export((array)$result, TRUE) : strval($result); $form['data']->setValue($result); } } }

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)
7.3.10.0080.00516.58
7.3.00.0080.00316.63
7.2.130.0110.00216.59
7.2.120.0040.00816.79
7.2.110.0030.00916.61
7.2.100.0040.01116.63
7.2.90.0020.00816.81
7.2.80.0050.01016.73
7.2.70.0050.00916.81
7.2.60.0050.00516.49
7.2.50.0070.00516.70
7.2.40.0050.00716.64
7.2.30.0070.00316.63
7.2.20.0030.00916.80
7.2.10.0030.00816.74
7.2.00.0040.00817.44
7.1.250.0000.01215.63
7.1.200.0030.00715.23
7.1.70.0080.00816.75
7.1.60.0040.00716.83
7.1.50.0160.00616.76
7.1.00.0030.05022.54
7.0.200.0030.01016.74
7.0.140.0030.07321.97
7.0.100.0070.08721.70
7.0.90.0030.08321.62
7.0.80.0000.05021.70
7.0.70.0070.07721.80
7.0.60.0070.04721.85
7.0.50.0000.07722.06
7.0.40.0000.07320.04
7.0.30.0070.05320.07
7.0.20.0070.05020.05
7.0.10.0030.06320.00
7.0.00.0030.05020.05
5.6.280.0000.07720.83
5.6.250.0070.07720.61
5.6.240.0100.07320.64
5.6.230.0100.07720.61
5.6.220.0100.05320.70
5.6.210.0070.06320.73
5.6.200.0070.04721.15
5.6.190.0070.06721.09
5.6.180.0000.08721.01
5.6.170.0100.04321.11
5.6.160.0070.07721.07
5.6.150.0030.07320.97
5.6.140.0030.05021.05
5.6.130.0000.09020.98
5.6.120.0030.08321.11
5.6.110.0000.08721.05
5.6.100.0100.05321.14
5.6.90.0030.08320.96
5.6.80.0030.07020.51
5.6.70.0070.05020.44
5.6.60.0070.05720.39
5.6.50.0030.04720.55
5.6.40.0070.03720.57
5.6.30.0070.04320.36
5.6.20.0100.07720.36
5.6.10.0100.07320.44
5.6.00.0030.08020.31
5.5.380.0070.08720.42
5.5.370.0100.05720.47
5.5.360.0070.04320.39
5.5.350.0000.08720.48
5.5.340.0070.07020.91
5.5.330.0000.06320.94
5.5.320.0070.04020.96
5.5.310.0030.08020.89
5.5.300.0100.07720.82
5.5.290.0100.07020.91
5.5.280.0000.05320.88
5.5.270.0070.04720.94
5.5.260.0070.06020.95
5.5.250.0130.05320.75
5.5.240.0030.07320.22
5.5.230.0030.08320.22
5.5.220.0030.08320.32
5.5.210.0030.07320.31
5.5.200.0170.06320.34
5.5.190.0100.07320.22
5.5.180.0000.06020.04
5.5.160.0070.05020.23
5.5.150.0100.07320.28
5.5.140.0030.08020.12
5.5.130.0000.05020.34
5.5.120.0070.07320.31
5.5.110.0000.05720.03
5.5.100.0130.06720.17
5.5.90.0070.07720.18
5.5.80.0070.06320.15
5.5.70.0100.06720.09
5.5.60.0100.07319.96
5.5.50.0030.07320.05
5.5.40.0000.08720.10
5.5.30.0130.06720.09
5.5.20.0030.07720.07
5.5.10.0100.07320.01
5.5.00.0070.08020.02
5.4.450.0030.08019.38
5.4.440.0100.07719.24
5.4.430.0000.07719.38
5.4.420.0030.07719.48
5.4.410.0030.07719.33
5.4.400.0030.06719.17
5.4.390.0070.06019.08
5.4.380.0070.06019.16
5.4.370.0030.07319.09
5.4.360.0030.07719.23
5.4.350.0030.08019.09
5.4.340.0100.07319.03
5.4.320.0030.07719.04
5.4.310.0000.08019.13
5.4.300.0030.05719.06
5.4.290.0100.07019.25
5.4.280.0070.07318.92
5.4.270.0030.07719.10
5.4.260.0130.07019.20
5.4.250.0130.06719.12
5.4.240.0100.07019.12
5.4.230.0030.05019.13
5.4.220.0000.08019.20
5.4.210.0100.06019.05
5.4.200.0000.07719.02
5.4.190.0100.07018.90
5.4.180.0030.04719.02
5.4.170.0000.04719.15
5.4.160.0000.06319.11
5.4.150.0100.07319.12
5.4.140.0030.07316.40
5.4.130.0070.07716.50
5.4.120.0070.06716.48
5.4.110.0030.03316.44
5.4.100.0000.04716.45
5.4.90.0000.06716.52
5.4.80.0030.06316.54
5.4.70.0100.06016.50
5.4.60.0000.05716.54
5.4.50.0030.04716.36
5.4.40.0030.07316.53
5.4.30.0130.06716.45
5.4.20.0000.04316.46
5.4.10.0030.06716.37
5.4.00.0030.06315.93
5.3.290.0000.06014.88
5.3.280.0100.07014.73
5.3.270.0030.07314.82
5.3.260.0000.08714.72
5.3.250.0000.04314.83
5.3.240.0030.07714.76
5.3.230.0100.04314.71
5.3.220.0130.07314.79
5.3.210.0000.05714.65
5.3.200.0100.03014.81
5.3.190.0070.05714.77
5.3.180.0030.07014.79
5.3.170.0030.07714.65
5.3.160.0030.06314.65
5.3.150.0030.04314.66
5.3.140.0000.07714.66
5.3.130.0000.06014.61
5.3.120.0000.06014.72
5.3.110.0070.07014.60
5.3.100.0030.06714.26
5.3.90.0000.04314.08
5.3.80.0000.07714.14
5.3.70.0070.07314.18
5.3.60.0000.07314.25
5.3.50.0070.05714.18
5.3.40.0070.06713.94
5.3.30.0000.04314.08
5.3.20.0130.06313.86
5.3.10.0030.06713.78
5.3.00.0100.06013.70

preferences:
37.44 ms | 401 KiB | 5 Q