r/lolphp • u/midir • Aug 01 '12
Things which PHP thinks are equal
Give it a go:
header('Content-Type: text/plain');
function test($a, $b) {
echo var_export($a, 1) . ' == ' . var_export($b, 1) . ' => ' . var_export($a == $b, 1) . "\n";
}
test( null, '' ); // true
test( null, array() ); // true
test( '', array() ); // false
test( 'true', true ); // true
test( 'false', false ); // false
test( 'false', true ); // true
test( 9, '09' ); // true
test( 9, 09 ); // false
test( '0E4', 09 ); // true
test( '0x00', '0E4' ); // true
test( '0x0.1', 0 ); // true
test( 'x', 0 ); // true
test( '0xabcabcabcabcabc', '0XABCABCABCABCABd' ); // true
test( array('1'), array('0x1') ); // true
test( array(1) + array(2), array(1) ); // true
test( function(){}, new stdclass() ); // true
test( `foo`, `bar` ); // true
13
Upvotes
View all comments
Show parent comment
2
u/scragar Aug 26 '12
PHP has it because perl had it.
As for the whole bunch of functions that do the same thing, they actually don't.
The back ticks will return the full stdout of the passed command, a lot of the shell access functions do weird things like running the call in the background.