Re: return parse error

From: Date: Fri, 13 Apr 2001 08:29:03 +0000
Subject: Re: return parse error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48422@lists.php.net to get a copy of this message
At 03:56 AM 4/13/2001, Peter Harkins wrote:
        This generates a parse error:
                mysql_connect("localhost", "root", "rootpw") or return("bar");
        But all the following work fine:
                mysql_connect("localhost", "root", "rootpw") or die("bar");
                mysql_connect("localhost", "root", "rootpw") or print("bar");
                if (!mysql_connect("localhost", "root", "rootpw")) {
                        return("bar");
                }
        Why? mysql_connect returns false on failure either way... I notice die
return isn't a function but a language construct. This is why the third working line with the curlybraces works, and without them it doesn't. include() is a language construct too. the particulars of using language constructs (like return() and include()) with control structure syntax are explained on the page for include(). http://us2.php.net/manual/en/function.include.php -j (aka sneak) ----------------------------------------------
sneak@datavibe.net      -           0x514DB5CB
he who lives these words shall not taste death becoming nothing yeah yeah forever liquid cool

« previous php.general (#48422) next »