Re: [PHP] Looking for caveats to the following code

2006-08-18 Thread Jochem Maas
Chris W. Parker wrote: > Hello, > > > if($result = do_something('hello')) > { > // do something with $result > } > else > { > // do some other stuff > } > > ?> > nothing wrong with this. like Adam mentioned you can check the expression to see if it is exactly false - and if you don

Re: [PHP] Looking for caveats to the following code

2006-08-18 Thread Richard Lynch
On Thu, August 17, 2006 5:19 pm, Chris W. Parker wrote: > The issue is whether or not this is a safe test. My initial thought is > that it is safe since I'm simply checking for true/false-ness. I > either > check for '!== false' explicitly or (in the case of the latter > example) > check that somet

RE: [PHP] Looking for caveats to the following code

2006-08-17 Thread tedd
At 4:16 PM -0700 8/17/06, Chris W. Parker wrote: tedd on Thursday, August 17, 2006 3:58 PM said: You can shorten it even further by: if(do_something('hello')) { // do something with $result } else { // do some other stuff } This a

Re: [PHP] Looking for caveats to the following code

2006-08-17 Thread Anas Mughal
Tedd, Actually, he seems to be needing the return value of the function inside the if block. So, he would need to do: if ($result = do_something('hello')) or, as Adam stated: if ( ($result = do_something('hello')) !== false ) Regards. -- Anas Mughal On 8/17/06, tedd <[EMAIL PROTECTED]

Re: [PHP] Looking for caveats to the following code

2006-08-17 Thread Robert Cummings
On Thu, 2006-08-17 at 18:58 -0400, tedd wrote: > At 3:19 PM -0700 8/17/06, Chris W. Parker wrote: > > > > >if($result = do_something('hello')) > >{ > > // do something with $result > >} > >else > >{ > > // do some other stuff > >} > > > >?> > > > >The issue is whether or not this is a safe test

Re: [PHP] Looking for caveats to the following code

2006-08-17 Thread tedd
At 3:19 PM -0700 8/17/06, Chris W. Parker wrote: The issue is whether or not this is a safe test. My initial thought is that it is safe since I'm simply checking for true/false-ness. I either check for '!== false' explicitly or (in the case of the latter example) check that something other than

[PHP] Looking for caveats to the following code

2006-08-17 Thread Chris W. Parker
Hello, While experimenting with some object stuff I stumbled upon something new (although not object related). Normally I would do this: Using the same function above I discovered I can do this: The issue is whether or not this is a safe test. My initial thought is that it is safe since I'