Forum Moderators: coopster

Message Too Old, No Replies

in PHP is it possible to return "twice"

ie. escaping first AND second function

         

amznVibe

4:55 pm on Feb 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some languages let you use return from a function more than once, and essentially cancel the function that called it.

I don't see how that's possible in PHP but I wanted to check just to be sure as it would make my life easier...

eelixduppy

6:30 pm on Feb 12, 2008 (gmt 0)



That is not something that would be valid, so no. You should be able to make a script that works in a similar manner. For instance, look at the following example:

function f1() {
#code here that does something
if(#something) {
return 1;
} else {
return 0;
}
} #end f1
#
function f2() {
#code that does something
if(f1()) { return 'something'; }
#otherwise proceed with rest of function
}