RE: [PHP] different and logic between PHP4 and PHP5

From: Date: Thu, 15 Mar 2007 12:18:00 +0000
Subject: RE: [PHP] different and logic between PHP4 and PHP5
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-250653@lists.php.net to get a copy of this message
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. | `------------------------------------------------------------'

« previous php.general (#250653) next »