i have this script which is workign just fine in server but in local wamp it is giving error
i have fopen is on
Warning: get_headers(): This function may only be used against URLs in C:\wamp\www\url\test5.php on line 8
<?php
$websitelink= 'http://www.brobible.com/girls/article/miley-cyrus-21st-birthday-party';
$html = file_get_contents($websitelink);
$doc = new DOMDocument();
@$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('img');
foreach ($tags as $tag) {
$data = get_headers($tag->getAttribute('src'),1);
$op7=''.$tag->getAttribute('src').'';
echo $op7;
}
?>
this code just works fine in server but not in local wamp server
I think you need to turn on the following PHP parameter.
You can find this in the php.ini file.
If you are using WAMPServer then you can also turn this on using the wampmanager icon menus as follows
I had a closer look at your code.
I would imagine that the data in
$tag->getAttribute('src')
does not have a full url at least in one case which is causing your error. It is probably using a relative address likeimg/imagename.png
and nothttp://example.com/img/imagename.png
That would explain the error message nicely.
Try adding an echo of what you are getting out of that statement.