Jump to content


Photo

Hey guys. Quick easy question.


  • Please log in to reply
2 replies to this topic

#1 dagnasty

dagnasty
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 30 October 2006 - 04:39 PM

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.

#2 dagnasty

dagnasty
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 30 October 2006 - 04:43 PM

Apparently I've been away from PHP for too long. The word I was looking for was return. I feel like an idiot.

#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 October 2006 - 04:44 PM

You can use "return". Example-
function my_func($var)
{
echo "123";
if($var>0) return;
echo "456";
}

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

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users