On Tue, 13 Jul 2004 14:35:32 -0500, Josh Close <[EMAIL PROTECTED]> wrote: > Well, the actual code is hard to tell. It's grabbed from a db so it > should be an int. But it's also run through some functions. That's why > I'd like a to tell what's going on better. > > The variable is always set. Basically > > $result = mssql_query($sql); > $row = mssql_fetch_array($result); > $var = $row[0]; > > So it should be an int. And if it's copied into a function it > shouldn't be changed. > > But doing > > if($var) > > doesn't seem to work after I upgraded versions. Which is making me > think that they changed how that works. > > And using is_string() or is_int() is pointless 'cause it doesn't > matter. I just want to know if the value != 0. > > The problem is, if 0 gets changed to "0" somewhere throughout. That's > why I've always used if($var) because it's usually not cared what the > type is, but it seems to now. >
AFAIK, PHP has for some time treated 0, '0', '', false, null, and array() all the same. If you do if($var) when $var is any of those, it results in false. If you want it to be non-zero, you should do !== 0. If you also don't want '0', you can do if((int)$var !== 0). -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php