Search code examples
phpreturnreturn-valuereturn-type

why PHP skip my return command?


I wonder why does this happen. I have code like this (I put return just for debugging):

public function foo($var) {
    do_something_here;
    return 'stop';
    if ($var > 0)
    { return 'true'; }
    return 'false';
}

and what I get is my function doesn't stop at return 'stop' line as supposed (it still continue to return 'true' (or 'false' if it false). Does it mean that return command must be put on the end line of function (or in conditional statement)?


Solution

  • I clean my browser cache and problem solved.