zero, nothing, nil.
Posted: Thu May 29, 2008 8:16 am
Something I've never understood about php is now it treats the int 0.
if you run the folowing code
result: 'matched', great! As expected.
now run:
ok, bit weird: result: 'matched'
now try:
somehow 0 is equal to 3 different things.
I've never understood this odd behaviour of php, that all strings are 0, is that because a string has 0 value?
if you run the folowing code
Code: Select all
function insane($value)
{
if($value==0)
{
print "matched";
}
}
insane(0);
now run:
Code: Select all
function insane($value)
{
if($value=='this')
{
print "matched";
}
}
insane(0);
now try:
Code: Select all
function insane($value)
{
if($value=='this')
{
print "this ";
}
if($value=='is')
{
print "is ";
}
if($value=='ridiculous')
{
print "ridiculous";
}
}
insane(0);
I've never understood this odd behaviour of php, that all strings are 0, is that because a string has 0 value?