When I use a valid URL like the following, file_get_contents
will return html code
$html = file_get_contents("http://www.google.com/");
but if the URL was invalid:
$html = file_get_contents("http://www.go1235ogle.com/"); //Invalid URL. This line give Error Message
my code will output an error message Notice: Trying to get property of non-object
if file_get_contents
can't open a given URL, I want to hide the error message it's outputting and skip the code bellow it with an if else
statement.
if (FALSE === $html)
{
//skip the code in here ?
}
but the code above doesn't help. Can you please tell me how can I correct this problem?