3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ?><!doctype html> <html> <head> <meta charset="utf-8"> <title>PHP comparisions</title> <link href='//fonts.googleapis.com/css?family=Inconsolata&amp;subset=latin,latin-ext' rel='stylesheet' type='text/css'> <link href='//fonts.googleapis.com/css?family=Roboto&amp;subset=latin,latin-ext' rel='stylesheet' type='text/css'> <style> * { font-size: 0.98em; } table { border-collapse: collapse; } th, td { margin: 0; padding: 7px; border: 1px solid #ddd; } th { font-weight: normal; background-color: #eee; } thead th:first-child { border-left: 0; border-top: 0; background-color: transparent; } th, .code { font-family: Inconsolata, monospace; white-space: pre; } tbody th { text-align: left; } td { text-align: center; } span.true { color: green; } span.false { color: red; opacity: 0.5; } .strict { display: none; } .hi { background-color: #ffa; } div { -moz-user-select: none; -khtml-user-select: none; -webkit-user-select: none; -o-user-select: none; user-select: none; } td, div { font-family: Roboto, sans-serif; } </style> </head> <body> <?php $values = array( '""', 'null', 'false', 'true', '0', '"0"', '-1', '"-1"', 'array()', 'array(null)', 'array(false)', 'array(0)', 'array("0")' ); ?><table> <thead> <tr> <th></th> <?php for($i = 0; $i < count($values); $i++) { ?><th><?php echo formatValue(getValue($values, $i)); ?></th><?php } ?> </tr> </thead> <tbody> <tr> <th>if(...)</th> <?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><td><?php echo formatCompare($Vi); ?></td><?php } ?> </tr> <tr> <th>empty</th> <?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><td><?php echo formatCompare(empty($Vi)); ?></td><?php } ?> </tr> <tr> <th>is_null</th> <?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><td><?php echo formatCompare(is_null($Vi)); ?></td><?php } ?> </tr> <tr> <th>is_numeric</th> <?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><td><?php echo formatCompare(is_numeric($Vi)); ?></td><?php } ?> </tr> <tr> <th>intval</th> <?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><td class="code"><?php echo formatValue(intval($Vi)); ?></td><?php } ?> </tr> <?php for($j = 0; $j < count($values); $j++) { $Vj = getValue($values, $j); ?><tr> <th><span class="loose">== </span><span class="strict">===</span> <?php echo formatValue($Vj); ?></th> <?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><td> <span class="loose"><?php echo formatCompare($Vi == $Vj); ?></span> <span class="strict"><?php echo formatCompare($Vi === $Vj); ?></span> </td><?php } ?></tr><?php } ?> </tbody> </table> <div style="user-select:none"> <label><input type="checkbox" id="strict"> strict comparisions</label> </div> <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> <script>(function() { $('#strict') .on('change', function() { $('.strict')[this.checked ? 'show' : 'hide'](); $('.loose')[this.checked ? 'hide' : 'show'](); }) .trigger('change') ; function hiCell(cell, hi) { var row = cell.parentNode.rowIndex, col = cell.cellIndex; $('thead tr th').eq(col)[hi ? 'addClass' : 'removeClass']('hi'); $('tbody tr').eq(row - 1).find('th').eq(0)[hi ? 'addClass' : 'removeClass']('hi'); $(cell)[hi ? 'addClass' : 'removeClass']('hi'); } $('td').on('mouseleave', function() { hiCell(this, false); }); $('td').on('mouseenter', function() { hiCell(this, true); }); })(); </script> </body> </html><?php function getValue($values, $index) { eval('$v = ' . $values[$index] . ';'); return $v; } function formatValue($o) { switch(gettype($o)) { case 'integer': $result = $o; break; case 'string': $result = '\'' . addslashes($o) . '\''; break; case 'NULL': $result = 'null'; break; case 'boolean': $result = $o ? 'true' : 'false'; break; case 'array': $values = array(); foreach($o as $v) { $values[] = formatValue($v); } $result = 'array(' . implode(', ', $values) . ')'; break; default: die(gettype($o)); } return $result; } function formatCompare($criteria) { if($criteria) { return '<span class="true">&#x2713;</span>'; } else { return '<span class="false">&#x2717;</span>'; } }

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.70.0110.01416.63
8.3.60.0080.00816.75
8.3.50.0130.01221.91
8.3.40.0140.01018.84
8.3.30.0130.00319.22
8.3.20.0030.00620.34
8.3.10.0030.00623.53
8.3.00.0040.00722.24
8.2.180.0150.00316.50
8.2.170.0070.01022.96
8.2.160.0120.00420.51
8.2.150.0070.00324.18
8.2.140.0000.00924.66
8.2.130.0030.00626.16
8.2.120.0060.00322.14
8.2.110.0070.00422.26
8.2.100.0060.00617.97
8.2.90.0090.00019.22
8.2.80.0040.00417.97
8.2.70.0090.00017.63
8.2.60.0070.00318.05
8.2.50.0060.00318.07
8.2.40.0040.00418.16
8.2.30.0000.00818.09
8.2.20.0030.00617.79
8.2.10.0000.01117.79
8.2.00.0030.00617.72
8.1.280.0070.01425.92
8.1.270.0090.00022.21
8.1.260.0100.00026.35
8.1.250.0030.00628.09
8.1.240.0070.00323.82
8.1.230.0030.01019.10
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0050.00517.48
8.1.190.0070.00317.66
8.1.180.0000.00918.10
8.1.170.0080.00518.49
8.1.160.0000.01022.06
8.1.150.0030.00618.70
8.1.140.0040.00417.57
8.1.130.0000.00817.88
8.1.120.0030.00617.50
8.1.110.0000.00917.53
8.1.100.0000.00817.43
8.1.90.0040.00417.54
8.1.80.0030.00517.34
8.1.70.0060.00317.38
8.1.60.0050.00517.64
8.1.50.0000.00917.56
8.1.40.0080.00017.58
8.1.30.0050.00517.62
8.1.20.0090.00017.75
8.1.10.0000.00917.69
8.1.00.0000.00917.53
8.0.300.0000.00818.77
8.0.290.0040.00417.30
8.0.280.0060.00318.42
8.0.270.0050.00317.19
8.0.260.0000.00916.93
8.0.250.0060.00316.91
8.0.240.0000.00916.90
8.0.230.0090.00017.08
8.0.220.0000.00816.96
8.0.210.0040.00416.84
8.0.200.0060.00316.93
8.0.190.0060.00317.05
8.0.180.0040.00416.96
8.0.170.0110.00017.01
8.0.160.0030.00616.83
8.0.150.0000.00916.78
8.0.140.0000.01116.86
8.0.130.0000.00713.40
8.0.120.0030.00616.98
8.0.110.0040.00417.00
8.0.100.0060.00316.85
8.0.90.0050.00316.94
8.0.80.0170.01716.83
8.0.70.0030.00616.92
8.0.60.0090.00017.06
8.0.50.0060.00316.91
8.0.30.0120.01217.11
8.0.20.0200.00817.40
8.0.10.0050.00316.95
8.0.00.0140.01616.88
7.4.330.0060.00015.00
7.4.320.0080.00016.65
7.4.300.0000.00716.66
7.4.290.0040.00416.57
7.4.280.0000.00816.66
7.4.270.0030.00616.55
7.4.260.0000.00816.64
7.4.250.0080.00016.53
7.4.240.0060.00316.66
7.4.230.0050.00316.46
7.4.220.0040.01816.70
7.4.210.0070.01216.65
7.4.200.0040.00416.37
7.4.190.0040.00416.70
7.4.160.0090.01416.75
7.4.150.0170.01017.40
7.4.140.0170.01317.86
7.4.130.0090.01616.49
7.4.120.0160.01216.61
7.4.110.0180.01016.46
7.4.100.0190.00716.46
7.4.90.0150.00816.58
7.4.80.0100.01316.64
7.4.70.0080.02316.63
7.4.60.0150.01216.61
7.4.50.0060.00316.65
7.4.40.0060.01322.77
7.4.30.0120.01516.59
7.4.00.0070.01314.92
7.3.330.0000.00613.25
7.3.320.0030.00313.23
7.3.310.0040.00416.43
7.3.300.0040.00416.46
7.3.290.0160.01016.37
7.3.280.0130.00816.39
7.3.270.0090.01517.40
7.3.260.0050.02016.57
7.3.250.0100.01516.49
7.3.240.0100.02316.63
7.3.230.0040.01816.60
7.3.210.0150.00916.54
7.3.200.0070.01719.39
7.3.190.0150.01516.59
7.3.180.0070.01716.71
7.3.170.0120.01216.38
7.3.160.0160.01316.46
7.3.120.0030.01714.82
7.2.330.0070.01816.91
7.2.320.0070.01716.83
7.2.310.0110.01516.90
7.2.300.0060.01716.66
7.2.290.0100.01016.88
7.1.70.0070.00317.26
7.1.60.0030.01419.29
7.1.50.0030.01716.95
7.0.200.0040.00416.82

preferences:
38.22 ms | 401 KiB | 5 Q