RE: [PHP] returning early from a function.

From: Warren Vail (Warren.Vail_at_schwab.com)
Date: 12/31/03


To: "'Chris W'" <1qazse4@cox.net>, php-general@lists.php.net
Date: Wed, 31 Dec 2003 10:17:48 -0700

Try;

if($s == 'this') return false;
        A
        *----------------- single = is an assignment.

Warren Vail

-----Original Message-----
From: Chris W [mailto:1qazse4@cox.net]
Sent: Monday, December 29, 2003 9:07 AM
To: php-general@lists.php.net
Subject: [PHP] returning early from a function.

I have a function that does several tests and if any are true it needs
to return false but I get an error about unexpected return for all
returns except for the last one.

function test($s)
{
   if($s = 'this') return false;
   if($s = 'that') return false;
   return true;
}

any ideas on how to make this work or why it doesn't work?

Chris W

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


Relevant Pages

  • RE: [PHP] Looking for help with forms/variables and an array!
    ... I am trying to get a php form variable into the above sql query. ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] Query question
    ... Subject: [PHP] Query question ... > PHP General Mailing List To unsubscribe, ...
    (php.general)
  • Re: [PHP] OS X 10.5.2
    ... if I really have to compile php with these included. ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ... it's not even an operating system. ...
    (php.general)
  • Re: [PHP] PHP & Text Messaging
    ... but I tried sending web messages to friends without it and, ... [PHP] PHP & Text Messaging ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)
  • Re: [PHP] 2 errors I can not understand
    ... [PHP] 2 errors I can not understand ... The next line is all that displays on the output html page: ... PHP General Mailing List ... To unsubscribe, visit: http://www.php.net/unsub.php ...
    (php.general)