Re: or return problem

From: Date: Tue, 07 Oct 2003 20:53:10 +0000
Subject: Re: or return problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-165371@lists.php.net to get a copy of this message
On Tue, 7 Oct 2003, Curt Zirzow wrote: >> function istrue() { >> return true; >> } >> function retor_test() { >> istrue() or return( "False" ); >> return "True"; >> } > return (istrue()? 'True': 'False'); > >hmm.. less typing, easier to understand and logically readable. This doesn't answer the problem because it does not follow the same logic as the orignial code example. In your example you want to return a value regardless of what istrue() returns. In my example I only wanted to return a value if istrue() failed, otherwise I wanted to continue in the scope of the function. That may not have been obvious because the example was a little contrived. Pat Carmody

« previous php.general (#165371) next »