Re: different and logic between PHP4 and PHP5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx		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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux