Re: php 4.3.7/5.0

From: Date: Tue, 13 Jul 2004 19:47:40 +0000
Subject: Re: php 4.3.7/5.0
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-190383@lists.php.net to get a copy of this message
On Tue, 2004-07-13 at 15:35, Josh Close wrote: > 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. You can typecast values as well, this may be a good way to achieve what you are looking for: if ((int)$var != 0) { // Do Something } Also, if you are going to use this variable as an integer later you can do the following to explicitly convert $var into an integer: $var = (int)$var; That should convert "0" into the integer value 0. Also, note the following: var_dump(0 == "0"); //bool(true) var_dump(0 === "0"); //bool(false) -- Adam Bregenzer adam@bregenzer.net http://adam.bregenzer.net/

« previous php.general (#190383) next »