RE: different and logic between PHP4 and PHP5

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

 



On 14 March 2007 01:00, Larry Garfield wrote:

> 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.

Ahem.  Yes it is.  At http://php.net/manual/en/language.types.string.php#language.types.string.casting it says:

> A boolean TRUE value is converted to the string "1", the
> FALSE value is represented as "" (empty string). This way
> you can convert back and forth between boolean and string
> values.

And I can testify from personal experience that this has been true since the very early days of 4.0.x (in fact, I still have a 4.0.5 installation hanging around that I tested it on...!!), so I do not know where the *BLEEP* the OP can have been getting that 0 from.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

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