I want to stop code execution (all application code). Actually I manage this code:
try
{
$connection = mysqli_connect( $this->_host,
$this->_username,
$this->_dbPass,
$this->_dbName );
if(mysqli_connect_errno())
{
throw new Exception("problem in connection.");
}
}
catch(Exception $ex)
{
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
echo json_encode(array("success" => false, "message" => $ex->getMessage()));
return; //<- application don't end
//exit(); //<- application end
}
Now if I call another method after the above code block that prints "hello world" with the return
statement I get the echo, but if I use exit()
I don't see any echo. So my question is: throw a new exception don't stop the application instance? I must use exit() for stop it after the exception instead of return?