S
S
Sergey Beloventsev2016-05-05 10:30:56
Yii
Sergey Beloventsev, 2016-05-05 10:30:56

Is it possible to disable the exception?

I'm trying to write a parser for this, I use the Snoopy.class class on some pages (not on all) it gives out such an exception.

PHP Warning – yii\base\ErrorException
fsockopen():

Checked outside yii the script issued a warning of this nature.
<b>Warning</b>:  fsockopen():  in <b>C:\OpenServer\domains\kinopoisk\Snoopy.class.php</b> on line <b>1142</b><br />

but the script worked out (more or less, but received the necessary information) The question can be somehow done in yii2, so that in case of a warning the script still continues to work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DieZz, 2016-05-05
@Sergalas

Why disable exceptions? They just say something is wrong. Learn to use them correctly and programming will become easier

try {
    //Тут что то делаем с сокетом
    fsockopen();
} catch (ErrorException $e) {
    //Что то пошло не так - обработаем исключение, например, так:
   echo $e->getMessage();
}

Then the execution of the code will not be interrupted, and we will know what happened and how to handle it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question