RE: [PHP] Break, Exit, Die, Kill, Maime and Stab
| From: | Chris Hayes | Date: | Thu, 03 Jul 2003 17:58:08 +0000 |
| Subject: | RE: [PHP] Break, Exit, Die, Kill, Maime and Stab | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153910@lists.php.net to get a copy of this message | ||
At 14:35 3-7-2003, you wrote:
-----Original Message----- From: Jeff Moser [mailto:jmoser@ihigh.com] Sent: 03 July 2003 13:07 So...why not write the entire included file as a function and then call that function instead of using include? I'd be interested, though, to hear if the return broke out of the include. Mike Ford: Well, it damn well better, as the manual page at http://www.php.net/include says it does! (You can return a value, as well, if you really must.)ah that's interesting. another option using multiple returns in one function: function testvars($var1,$var2)
{ if ($var1<1) return 'var1 must be a positive integer';
if ($var2=='bad') return 'var2 is bad!';
//this line is only reached when all vars are tested ok:
return true;
}
$result=testvars($var1,$var2);
if ($result!=true) {
echo $result.'<br>Please warp to your previous location';
exit();
}