RE: different and logic between PHP4 and PHP5

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

 



On Thu, 2007-03-15 at 10:30 +0000, Ford, Mike wrote:
> On 12 March 2007 23:06, Richard Lynch wrote:
> 
> > On Mon, March 12, 2007 1:53 pm, Vieri wrote:
> > > The following code:
> > > 
> > > <?php
> > > $b="";
> > > $c="df";
> > > $a=($b and $c);
> > 
> > Why in the world would you use 'and' on two strings?
> > 
> > What is that supposed to even mean?...
> > 
> > Type-cast them to numbers if you want to use 'and'
> 
> Why in the world would you use 'and' on two numbers?
>  
> What is that supposed to even mean?...
> 
> Type-cast them to bool if you want to use 'and'
> 
> ... ;) ;)

Not that I'm advocating the style (since it's less readable) but it is a
shortcut to a desired result. You save the cast operation on both
operands, and you save using an if/else clause or the ternary operator.
If you understand your type juggling then it's not a mystery what is
happening (yes I know Mike knows his type juggling -- I'm speaking in
general ;)

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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