Re: Re: function returning true or errors

From: Date: Thu, 18 Apr 2002 16:05:55 +0000
Subject: Re: Re: function returning true or errors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93558@lists.php.net to get a copy of this message
On Thursday, April 18, 2002, at 11:38 AM, Julio Nobrega Trabalhando wrote:
function custom_function() {
    if ($error == 0) {
        return true;
    } else {
        return "Error!";
    }
} if (custom_function() != "Error!") {
    echo "Success";
} else {
    echo "Error";
}
Your way would work perfect except that I simplified the function I posted, for illustrative purposes -- a mistake, I realize. The returned error message is actually composed of an imploded array, whose contents are entirely dependent on the code in the function (basically it varies depending on circumstances, so I can't write a test for it). I ended up just performing the checks in the script itself, rather than in a function, because I was only using a function as a subroutine to keep my script's switch() statement nice and clean. But in this case, it just was too much trouble (I was also running into a situation where I had to deal with a global variable, etc). Since I don't really need this anywhere else in the script, I don't really even need it to be a function. Thanks for your input though, Julio. Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown pricee@hhbrown.com

« previous php.general (#93558) next »