Jump to content

Archived

This topic is now archived and is closed to further replies.

dagnasty

Hey guys. Quick easy question.

Recommended Posts

What's the word to terminate a function?

Google keeps turning up exit and die, but I just want to exit the function, not cancel script execution.

Share this post


Link to post
Share on other sites
Apparently I've been away from PHP for too long. The word I was looking for was return. I feel like an idiot.

Share this post


Link to post
Share on other sites
You can use "return". Example-
[code]function my_func($var)
{
echo "123";
if($var>0) return;
echo "456";
}[/code]

if var is a positive number the function will echo 123456. If it's not it will echo 123.

Orio.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.