Re: php 4.3.7/5.0
| From: | Josh Close | Date: | Tue, 13 Jul 2004 20:09:20 +0000 |
| Subject: | Re: php 4.3.7/5.0 | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190384@lists.php.net to get a copy of this message | ||
I think I'll just have to typecast everything, that should always work then.
On Tue, 13 Jul 2004 15:47:40 -0400, Adam Bregenzer <adam@bregenzer.net> wrote:
> 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/
>
>
--
-Josh