Newbit
Newbit

Reputation: 13

PHP - Is it possible to return the return command?

Say we have:

function foo() {
    bar();
    echo "hello stackoverflow, this is my first question, you helped me so many times, I can't even count it, you are great! <3";
}
function bar() {
    return;
}
foo();

I know it's rude but is it possible to let bar() return a "return command" like return return; to tell foo() to immediately return aswell? I know you can do it with a check in foo() if you set a specific return value in bar(), but is it possible without in some way?

Upvotes: 1

Views: 91

Answers (1)

Er. Amit Joshi
Er. Amit Joshi

Reputation: 645

No because Simply after return no statement of function execute.

And return return is a

PHP Parse error: syntax error, unexpected 'return'

Very nice explanation of return in documentation

Upvotes: 1

Related Questions