Is it possible to do this?
$objetc -> runAndFinish();
echo "this should not be echoed";
instead of this?
$objetc -> runAndFinish();
exit();
echo "this should not be echoed";
So runAndFinish(); method would somehow end the script processing. Is it possible?
As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement. The closing tag of a block of PHP code automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a PHP block.
exit(): The function terminates the execution of a script.
Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.
Put an exit(); inside of your classes runAndFinish(); method
class someClass{
function runAndFinish(){
exit();
}
}
$obj = new someClass();
$obj->runAndFinish();
echo "not gonna print";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With