var_dump((bool) '0');
Posted: Tue Apr 03, 2007 2:41 pm
Code: Select all
var_dump((bool) '0'); // false
var_dump((bool) '00'); // trueP.S I feel dumb, I was sure they were both false
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
var_dump((bool) '0'); // false
var_dump((bool) '00'); // trueCode: Select all
var_dump((bool)(int) "00");Code: Select all
var_dump((bool)(int) "00"); // === trueActually that casts to boolean false. The string "00" casts to an integer as 0... The integer 0 casts to boolean as false.Oren wrote:Anyway... I'm still confusedCode: Select all
var_dump((bool)(int) "00"); // === true
Yes I did, more than once. It still seems a bit odd to me, but whatever...feyd wrote:Did you read http://php.net/language.types.boolean#l ... an.casting?
Code: Select all
var_dump('123' == 123); // true
var_dump('0xCafe' == 51966); // true
var_dump('0123' == 0123); // false???