In short, NO . Thanks, damn it, it will make this a very strange language, where you probably wonβt rely on returning any function.
You can use exceptions, however check the manual . That way, you can force the called methods to influence the flow control in the called party - try not to abuse it to do this, though, since the code can get pretty ugly with too much of this.
Here is an example of using exceptions to check:
class ValidationException extends Exception { } function checkNotEmpty($input) { if (empty($input)){ throw new ValidationException('Input is empty'); } return $input; } function checkNumeric($input) { if (!is_numeric($input)) { throw new ValidationException('Input is not numeric'); } return $input; } function doStuff() { try { checkNotEmpty($someInput); checkNumeric($otherInput);
source share