9three Posted April 18, 2009 Share Posted April 18, 2009 If an exception is thrown, does it not go any further or will it continue? Example: public function connect() { $this->link = mysqli($this->host, $this->username, $this->password, $this->dbname); if (!$this->link) Throw New Exception(mysqli_error); return $this->link; } If an exception is thrown will it still return $this->link ? Quote Link to comment https://forums.phpfreaks.com/topic/154672-solved-exception-stops-execution/ Share on other sites More sharing options...
Mchl Posted April 18, 2009 Share Posted April 18, 2009 Whenever exception is thrown, the execution of code is moved to the 'nearest' catch block. Quote Link to comment https://forums.phpfreaks.com/topic/154672-solved-exception-stops-execution/#findComment-813362 Share on other sites More sharing options...
9three Posted April 18, 2009 Author Share Posted April 18, 2009 Right, the exception is caught but will it execute the rest? Quote Link to comment https://forums.phpfreaks.com/topic/154672-solved-exception-stops-execution/#findComment-813365 Share on other sites More sharing options...
Mchl Posted April 18, 2009 Share Posted April 18, 2009 When an exception is thrown' date=' code following the statement will not be executed, and PHP will attempt to find the first matching catch block. If an exception is not caught, a PHP Fatal Error will be issued with an "Uncaught Exception ..." message, unless a handler has been defined with set_exception_handler(). [/quote'] Quote Link to comment https://forums.phpfreaks.com/topic/154672-solved-exception-stops-execution/#findComment-813368 Share on other sites More sharing options...
9three Posted April 18, 2009 Author Share Posted April 18, 2009 thanks Quote Link to comment https://forums.phpfreaks.com/topic/154672-solved-exception-stops-execution/#findComment-813370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.