[PHP] or return problem

2003-10-07 Thread Pat Carmody


Calling the following retor_test() function causes a Parse error: parse
error, unexpected T_RETURN message when the script is run:

function istrue() {
  return true;
}
function retor_test() {
  istrue() or return( False );
  return True;
}

The problem is with the or return part.  Any ideas why?  I realize that
I could use an if statement instead, but I'm a lazy, lazy man and I don't
want to.


Pat Carmody

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] or return problem

2003-10-07 Thread Pat Carmody

So far everyone is telling me that it won't work, but no one is telling me
why. (btw I did search extensively for the answer to this question but so
far have found nothing).  Robert, could you be more specific in your
reference to the http://www.php.net documentation?  I see nothing on the
basic syntax page that addresses this.

Pat Carmody

On Tue, 7 Oct 2003, Robert Cummings wrote:

On Tue, 2003-10-07 at 13:02, Pat Carmody wrote:


 Calling the following retor_test() function causes a Parse error: parse
 error, unexpected T_RETURN message when the script is run:

 function istrue() {
   return true;
 }
 function retor_test() {
   istrue() or return( False );
   return True;
 }

 The problem is with the or return part.  Any ideas why?  I realize that
 I could use an if statement instead, but I'm a lazy, lazy man and I don't
 want to.

Your laziness is causing you problems. Please check out ALL of the
documenation located at http://www.php.net since this is covered under
basic syntax and we don't cater to lazy people (at the very least *I*
don't cater to lazy people).

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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] or return problem

2003-10-07 Thread Pat Carmody


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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php