I've been up for hours now researching error handling with simple_html_dom
it's for a vine filter website. I need to make it so that if $videoid
has no string content it will either A. End simple_html_dom and output a normal string like "no content is here" kind of thing. I'm still new so excuse my mistakes..
My error result: http://i.imgur.com/IyC5mJu.png
my code
<?php
include('include/simple_html_dom.php');
$website = 'http://vine.co/v/';
// if this is left empty site will display php errors saying page not found.
$videoid = 'haiKqBFA9Yw';
$html = file_get_html($website . $videoid);
if ($html->find('meta[property=og:image]')) {
foreach ($html->find('meta[property=og:image]') as $element) {
$img[] = $element->attr['content'];
}
}
//Change http to https and remove versionId=
$element->content = str_replace( 'https://', 'http://', $element->content );
$element->content = str_replace( 'versionId=', '', $element->content );
//Remove extra version id junk
$img = $element->content;
$element->content = substr($img, 0, strpos($img, "?"));
// My attempt using isset to determine if it has no content or if it does.. it did not work.
if (isset($videoid)) {
echo $element->content;
}else{
echo "It appears $videoid is empty.";
}
?>
Pulling my hair out on this one and I have a strong feeling it's an easy fix. Could someone please give me a hand?
Other work arounds attempted:
if string is amount of website
than kill dom