Skip to content

Instantly share code, notes, and snippets.

@hnw
Created November 20, 2014 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnw/01a44a1ff98e6abb74e4 to your computer and use it in GitHub Desktop.
Save hnw/01a44a1ff98e6abb74e4 to your computer and use it in GitHub Desktop.
<?php
$values = array(null, true, false, 0, 0.0, '', ' ', '0', '00', '0.0', '0x0', '0X0', 1, 1.0, '1', '01', '1.0', '0x1', '0X1', '1e0', '1E0', 'a', '1a', INF, -INF, NAN, PHP_INT_MAX, ~PHP_INT_MAX, 9223372036854775808.0, '9223372036854775807', '9223372036854775807.0', '9223372036854775808', '9223372036854775808.0', '9999999999999999999.0', '9999999999999999999.1', '10000000000000000000.0', '10000000000000000000.00', '1e19', '1E19');
foreach ($values as $a) {
if (is_float($a)) {
$a_str = sprintf('%-20.1f', $a);
} else {
$a_str = var_export($a, true);
}
foreach ($values as $b) {
if (is_float($b)) {
$b_str = sprintf('%-20.1f', $b);
} else {
$b_str = var_export($b, true);
}
if ($a == $b) {
$op = '==';
} elseif ($a > $b) {
$op = '>';
} elseif ($a < $b) {
$op = '<';
} else {
$op = '!=';
}
echo $a_str,$op,$b_str,"\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment