Simple HTML DOM Parser Error Handling

I am using SimpleHTMLDOM Parser to browse a website and I would like to know if there is a way to handle errors. For example, if the link is broken, there is no point in advancing through the code and looking for a document.

Thank.

+2


source to share


2 answers


<?php
$html = file_get_html('http://www.google.com/');

foreach($html->find('a') as $element)
{
  if(empty($element->href))
  {
    continue; //will skip <a> without href
  }

  echo $element->href . "<br>\n";
}
?>

      



+2


source


cycle and continue?



0


source







All Articles