How can I check if a given URL refers to a webpage or a raw file? For now, I check the whole file for containing the string <html>
but that is neither effective nor reliable.
$content = file_get_contents($url);
if($content)
{
// is directory
if(strrpos($content, "<html>"))
{
echo $url . " is a folder." . "<br>";
}
else // use raw file...
}
else echo $url . " was not found." . "<br>";