@ 2014-04-16T08:19:14Z <?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&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Roboto&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">✓</span>';
}
else {
return '<span class="false">✗</span>';
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 8.3.7 0.011 0.014 16.63 8.3.6 0.008 0.008 16.75 8.3.5 0.013 0.012 21.91 8.3.4 0.014 0.010 18.84 8.3.3 0.013 0.003 19.22 8.3.2 0.003 0.006 20.34 8.3.1 0.003 0.006 23.53 8.3.0 0.004 0.007 22.24 8.2.18 0.015 0.003 16.50 8.2.17 0.007 0.010 22.96 8.2.16 0.012 0.004 20.51 8.2.15 0.007 0.003 24.18 8.2.14 0.000 0.009 24.66 8.2.13 0.003 0.006 26.16 8.2.12 0.006 0.003 22.14 8.2.11 0.007 0.004 22.26 8.2.10 0.006 0.006 17.97 8.2.9 0.009 0.000 19.22 8.2.8 0.004 0.004 17.97 8.2.7 0.009 0.000 17.63 8.2.6 0.007 0.003 18.05 8.2.5 0.006 0.003 18.07 8.2.4 0.004 0.004 18.16 8.2.3 0.000 0.008 18.09 8.2.2 0.003 0.006 17.79 8.2.1 0.000 0.011 17.79 8.2.0 0.003 0.006 17.72 8.1.28 0.007 0.014 25.92 8.1.27 0.009 0.000 22.21 8.1.26 0.010 0.000 26.35 8.1.25 0.003 0.006 28.09 8.1.24 0.007 0.003 23.82 8.1.23 0.003 0.010 19.10 8.1.22 0.003 0.006 17.74 8.1.21 0.004 0.004 18.77 8.1.20 0.005 0.005 17.48 8.1.19 0.007 0.003 17.66 8.1.18 0.000 0.009 18.10 8.1.17 0.008 0.005 18.49 8.1.16 0.000 0.010 22.06 8.1.15 0.003 0.006 18.70 8.1.14 0.004 0.004 17.57 8.1.13 0.000 0.008 17.88 8.1.12 0.003 0.006 17.50 8.1.11 0.000 0.009 17.53 8.1.10 0.000 0.008 17.43 8.1.9 0.004 0.004 17.54 8.1.8 0.003 0.005 17.34 8.1.7 0.006 0.003 17.38 8.1.6 0.005 0.005 17.64 8.1.5 0.000 0.009 17.56 8.1.4 0.008 0.000 17.58 8.1.3 0.005 0.005 17.62 8.1.2 0.009 0.000 17.75 8.1.1 0.000 0.009 17.69 8.1.0 0.000 0.009 17.53 8.0.30 0.000 0.008 18.77 8.0.29 0.004 0.004 17.30 8.0.28 0.006 0.003 18.42 8.0.27 0.005 0.003 17.19 8.0.26 0.000 0.009 16.93 8.0.25 0.006 0.003 16.91 8.0.24 0.000 0.009 16.90 8.0.23 0.009 0.000 17.08 8.0.22 0.000 0.008 16.96 8.0.21 0.004 0.004 16.84 8.0.20 0.006 0.003 16.93 8.0.19 0.006 0.003 17.05 8.0.18 0.004 0.004 16.96 8.0.17 0.011 0.000 17.01 8.0.16 0.003 0.006 16.83 8.0.15 0.000 0.009 16.78 8.0.14 0.000 0.011 16.86 8.0.13 0.000 0.007 13.40 8.0.12 0.003 0.006 16.98 8.0.11 0.004 0.004 17.00 8.0.10 0.006 0.003 16.85 8.0.9 0.005 0.003 16.94 8.0.8 0.017 0.017 16.83 8.0.7 0.003 0.006 16.92 8.0.6 0.009 0.000 17.06 8.0.5 0.006 0.003 16.91 8.0.3 0.012 0.012 17.11 8.0.2 0.020 0.008 17.40 8.0.1 0.005 0.003 16.95 8.0.0 0.014 0.016 16.88 7.4.33 0.006 0.000 15.00 7.4.32 0.008 0.000 16.65 7.4.30 0.000 0.007 16.66 7.4.29 0.004 0.004 16.57 7.4.28 0.000 0.008 16.66 7.4.27 0.003 0.006 16.55 7.4.26 0.000 0.008 16.64 7.4.25 0.008 0.000 16.53 7.4.24 0.006 0.003 16.66 7.4.23 0.005 0.003 16.46 7.4.22 0.004 0.018 16.70 7.4.21 0.007 0.012 16.65 7.4.20 0.004 0.004 16.37 7.4.19 0.004 0.004 16.70 7.4.16 0.009 0.014 16.75 7.4.15 0.017 0.010 17.40 7.4.14 0.017 0.013 17.86 7.4.13 0.009 0.016 16.49 7.4.12 0.016 0.012 16.61 7.4.11 0.018 0.010 16.46 7.4.10 0.019 0.007 16.46 7.4.9 0.015 0.008 16.58 7.4.8 0.010 0.013 16.64 7.4.7 0.008 0.023 16.63 7.4.6 0.015 0.012 16.61 7.4.5 0.006 0.003 16.65 7.4.4 0.006 0.013 22.77 7.4.3 0.012 0.015 16.59 7.4.0 0.007 0.013 14.92 7.3.33 0.000 0.006 13.25 7.3.32 0.003 0.003 13.23 7.3.31 0.004 0.004 16.43 7.3.30 0.004 0.004 16.46 7.3.29 0.016 0.010 16.37 7.3.28 0.013 0.008 16.39 7.3.27 0.009 0.015 17.40 7.3.26 0.005 0.020 16.57 7.3.25 0.010 0.015 16.49 7.3.24 0.010 0.023 16.63 7.3.23 0.004 0.018 16.60 7.3.21 0.015 0.009 16.54 7.3.20 0.007 0.017 19.39 7.3.19 0.015 0.015 16.59 7.3.18 0.007 0.017 16.71 7.3.17 0.012 0.012 16.38 7.3.16 0.016 0.013 16.46 7.3.12 0.003 0.017 14.82 7.2.33 0.007 0.018 16.91 7.2.32 0.007 0.017 16.83 7.2.31 0.011 0.015 16.90 7.2.30 0.006 0.017 16.66 7.2.29 0.010 0.010 16.88 7.1.7 0.007 0.003 17.26 7.1.6 0.003 0.014 19.29 7.1.5 0.003 0.017 16.95 7.0.20 0.004 0.004 16.82
preferences:dark mode live preview
38.22 ms | 401 KiB | 5 Q