Answer the question
In order to leave comments, you need to log in
How to catch a construction exception like $noObject->func();?
Please tell me how to catch the exception in this situation:
$html = str_get_html($text);
$html->find('div[class="image"]',0)->find('a',0)->href;
try {
$html = str_get_html($text);
$html->find('div[class="image"]',0)->find('a',0)->href;
} catch (\Exception $e) {
throw new RuntimeException("tag not found");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question