Re: different and logic between PHP4 and PHP5
| From: | Larry Garfield | Date: | Wed, 14 Mar 2007 01:00:08 +0000 |
| Subject: | Re: different and logic between PHP4 and PHP5 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250508@lists.php.net to get a copy of this message | ||
On Tuesday 13 March 2007 7:50 am, Vieri wrote:
> <?php
> //$b=3;
> $c=3;
> $a=($b and $c);
> echo "A = ".$a;
> ?>
>
> in PHP4 I get:
> A = 0
> and in PHP5 I get:
> A =
> I could call this lazyness on our part or code
> portability through PHP versions or better yet, bad
> inherited coding right from the start.
A little bit of each, I think. :-)
"and", like &&, is a boolean operation. It will return either TRUE or FALSE.
The string representation of TRUE and FALSE is, AFAIK, not defined. It looks
like the effect of toString(boolean) changed from "false becomes 0" to "false
becomes empty string". That's quite annoying when both are logically false
but could have side-effects like this.
OTOH, relying on a boolean data type to have a given string value in the first
place is a bad idea to start with. :-) Find whoever you inherited the code
from and shoot him. (Really, I know how badly inherited code can suck.)
--
Larry Garfield AIM: LOLG42
larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson