Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
notice is not an exception. You can hang your own error handler that will transform notice into exception.
php.net/manual/ru/class.errorexception.php
ideone.com/VEuyrf - example
https://github.com/DmitryKoterov/php_exceptionizer...
Yii has nothing to do with it.
PHP does not throw an exception when accessing an array element that does not exist. At best, it will throw out NOTICE or WARNING some thread, but this is not caught in try..catch. PHP has separate functions for handling such errors: php.net/manual/ru/book.errorfunc.php
Although Yii 2, in my opinion, made it so that php errors are converted into exceptions.
Why turn Notice into real Exception? Well, if you really need it:
try{
if(!isset($a['some_index']){ throw new Exception('Index does not exists!'); }
} catch (Exception $ex) { }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question