3v4l.org

run code in 300+ PHP versions simultaneously
<?php function http_protocol() { return (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'; } function http_host() { return $_SERVER['HTTP_HOST']; } function http_uri() { return parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); } function http_refactored_query_strings() { $queries = explode('&', $_SERVER['QUERY_STRING']); $refactoredQueries = []; foreach( $queries as $query ) { $refactoredQueries[] = filter_var(explode('=', $query)[1], FILTER_SANITIZE_STRING); } $queries = implode('/', $refactoredQueries); return $queries ?: ''; } function http_refactored_url() { return http_protocol() . http_host() . http_uri() . http_refactored_query_strings(); } echo http_refactored_url(); ?> <?php class Pagination { public $current_page; public $per_page; public $total_count; public $pages_articles; public function __construct($page=1, $per_page=20, $total_count=0) { $this->current_page = (int)$page; $this->per_page = (int)$per_page; $this->total_count = (int)$total_count; $this->pages_articles=array( '<div class="article-loop"><img src="http://i.imgur.com/CmU3tnl.jpg"></div>', '<div class="article-loop"><img src="http://i.imgur.com/TDdxS9H.png"></div>', '<div class="article-loop"><img src="http://i.imgur.com/39rpmwB.jpg"></div>', '<div class="article-loop"><img src="http://i.imgur.com/1lBZQ1B.png"></div>', '<div class="article-loop"><img src="https://i.imgur.com/Y5Ld4Qfh.jpg"></div>', '<div class="article-loop"><img src="http://i.imgur.com/wQVPRVp.png"></div>'); $this->total_count = sizeof($this->pages_articles); } public function offset() { return ($this->current_page - 1) * $this->per_page; } public function total_pages() { return ceil($this->total_count/$this->per_page); } public function previous_page() { return $this->current_page - 1; } public function next_page() { return $this->current_page + 1; } public function has_previous_page() { return $this->previous_page() >= 1 ? true : false; } public function has_next_page() { return $this->next_page() <= $this->total_pages() ? true : false; } } $page = !empty($_GET['page']) ? (int)$_GET['page'] : 1; $per_page = 3; $pagination = new Pagination($page, $per_page, $total_count); ?> <html> <body> <div> <?php $i = $pagination->offset() ; $limit = $pagination->per_page; while($i<$pagination->total_count && $limit>0) { echo $pagination->pages_articles[$i]."<br>"; $i++; $limit--; } ?> </div> <ul> <?php if($pagination->has_previous_page()) { echo '<li style="display:inline"><a href="?page='.$pagination->previous_page().'">&laquo;</a></li>'; } else { echo '<li style="display:inline" class="disabled"><a href="#">&laquo;</a></li>'; } for($i=1; $i<=$pagination->total_pages(); $i++) { echo '<a href="?page='.$i.'"><li style="display:inline; margin-left:5px; margin-right:5px">'.$i.'</li></a>'; } if($pagination->has_next_page()) { echo '<li style="display:inline"><a href="?page='.$pagination->next_page().'">&raquo;</a></li>'; } else { echo '<li style="display:inline" class="disabled"><a href="#">&raquo;</a></li>'; } ?> </ul> </body> </html>

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)
8.3.60.0070.01117.00
8.3.50.0090.00616.59
8.3.40.0110.00718.91
8.3.30.0030.01218.79
8.3.20.0040.00420.32
8.3.10.0050.00321.72
8.3.00.0050.00317.84
8.2.180.0180.00416.60
8.2.170.0070.00722.96
8.2.160.0000.01320.47
8.2.150.0070.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00419.27
8.2.120.0040.00426.35
8.2.110.0000.00920.38
8.2.100.0030.00918.17
8.2.90.0000.00818.16
8.2.80.0040.00418.05
8.2.70.0030.00518.05
8.2.60.0040.00418.16
8.2.50.0030.00618.10
8.2.40.0000.00820.64
8.2.30.0040.00419.38
8.2.20.0000.00818.25
8.2.10.0080.00018.21
8.2.00.0000.00718.15
8.1.280.0080.00825.92
8.1.270.0070.00023.96
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0070.00320.57
8.1.230.0040.00721.16
8.1.220.0030.00517.78
8.1.210.0050.00318.82
8.1.200.0060.00317.47
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0050.00319.08
8.1.160.0000.00719.04
8.1.150.0060.00320.59
8.1.140.0000.00819.57
8.1.130.0030.00318.82
8.1.120.0050.00517.38
8.1.110.0000.00817.43
8.1.100.0000.00717.43
8.1.90.0070.00417.42
8.1.80.0000.00717.52
8.1.70.0070.00017.55
8.1.60.0060.00317.54
8.1.50.0000.00817.61
8.1.40.0020.00517.59
8.1.30.0000.00817.70
8.1.20.0040.00417.78
8.1.10.0060.00317.55
8.1.00.0000.00817.54
8.0.300.0070.00019.73
8.0.290.0040.00416.88
8.0.280.0040.00418.48
8.0.270.0070.00017.25
8.0.260.0000.00716.95
8.0.250.0000.00717.11
8.0.240.0070.00017.07
8.0.230.0000.00717.04
8.0.220.0030.00517.01
8.0.210.0030.00316.98
8.0.200.0000.00817.00
8.0.190.0030.00617.07
8.0.180.0000.00817.07
8.0.170.0040.00416.92
8.0.160.0000.00717.00
8.0.150.0000.00716.93
8.0.140.0040.00416.86
8.0.130.0030.00313.44
8.0.120.0070.00017.04
8.0.110.0060.00316.86
8.0.100.0070.00016.88
8.0.90.0000.00817.05
8.0.80.0120.00316.94
8.0.70.0100.00017.02
8.0.60.0000.00816.89
8.0.50.0080.00017.08
8.0.30.0120.00717.17
8.0.20.0090.01217.41
8.0.10.0040.00417.16
8.0.00.0070.01617.02
7.4.330.0000.00515.55
7.4.320.0000.00716.55
7.4.300.0000.00616.69
7.4.290.0030.00316.59
7.4.280.0080.00016.56
7.4.270.0030.00316.54
7.4.260.0060.00013.33
7.4.250.0030.00316.42
7.4.240.0000.00816.63
7.4.230.0070.00016.35
7.4.220.0090.01016.67
7.4.210.0070.00716.65
7.4.200.0070.00016.53
7.4.160.0050.01116.45
7.4.150.0120.00617.40
7.4.140.0100.00917.86
7.4.130.0130.01616.48
7.4.120.0100.01116.62
7.4.110.0070.01016.55
7.4.100.0070.01016.74
7.4.90.0150.00916.47
7.4.80.0140.00819.39
7.4.70.0080.00916.54
7.4.60.0000.01616.52
7.4.50.0060.00916.41
7.4.40.0060.01116.60
7.4.30.0100.01416.48
7.4.00.0100.00714.89
7.3.330.0030.00313.45
7.3.320.0050.00013.46
7.3.310.0000.00816.51
7.3.300.0000.00716.34
7.3.290.0070.00816.48
7.3.280.0070.00816.46
7.3.270.0100.00717.40
7.3.260.0080.00816.53
7.3.250.0100.01016.53
7.3.240.0130.00516.45
7.3.230.0120.00616.63
7.3.210.0130.00616.62
7.3.200.0130.00316.58
7.3.190.0130.00316.52
7.3.180.0080.01216.54
7.3.170.0220.00716.60
7.3.160.0170.00316.55
7.2.330.0000.01816.91
7.2.320.0030.01516.82
7.2.310.0060.01016.82
7.2.300.0120.01216.56
7.2.290.0060.01116.82
7.2.60.0100.00316.94
7.2.00.0210.00719.16
7.1.200.0070.00715.77
7.1.100.0030.01018.36
7.1.70.0000.01217.16
7.1.60.0230.00335.19
7.1.50.0200.00734.55
7.1.40.0190.00634.35
7.1.30.0160.01034.62
7.1.20.0160.01234.71
7.1.10.0000.01216.66
7.1.00.0030.01416.62
7.0.200.0000.01316.54
7.0.190.0030.00916.68
7.0.180.0030.00916.23
7.0.170.0030.01016.19
7.0.160.0000.01216.19
7.0.150.0000.01116.04
7.0.140.0030.00916.29
7.0.130.0060.00616.58
7.0.120.0040.01116.70
7.0.110.0050.01016.48
7.0.100.0060.00616.25
7.0.90.0030.01216.38
7.0.80.0090.00316.44
7.0.70.0000.01316.54
7.0.60.0090.00615.91
7.0.50.0060.00616.21
7.0.40.0060.00916.64
7.0.30.0090.00316.58
7.0.20.0000.01716.42
7.0.10.0060.01116.46
7.0.00.0000.01316.18

preferences:
51.4 ms | 400 KiB | 5 Q