简体   繁体   中英

php - why won't my data show up in firefox

I'm using the following code in an index.php page to display content from one page on another domain. However, it works fine in IE, but when I load the page in Firefox, its missing php data.

Am I doing something wrong or does firefox not allow this? Any help appreciated.

$domain = $_SERVER['HTTP_HOST'];
$crawl = "http://www.mysite.co.uk/page.php?domain=$domain";
$fd = fopen($crawl, "r");
while($buf = fgets($fd,1024))
{
echo $buf;
}
fclose($fd);

PLEASE NOTE: if I load the target url directly it works just fine

Try view source. It might be there, and just not displayed depending on the content.

In many cases such problems are caused by browser cache, and I faced with similar situation with Firefox particularly. Try cleaning it cache, then open page again.

Delete the file on the server, upload this code (its nothing more than a clearer solution which doesn't require allow_url_fopen which is dangerous).

Then clear the browser caches and see if it works:

<?
$domain = $_SERVER['HTTP_HOST'];
$crawl = "http://www.mysite.co.uk/page.php?domain=$domain";

$request = curl_init($crawl);    
print curl_exec($request);
curl_close($request); 
?>

Edit: If this doesn't work, upload a file with <? echo $_SERVER['HTTP_HOST']; ?> <? echo $_SERVER['HTTP_HOST']; ?> <? echo $_SERVER['HTTP_HOST']; ?> and check if it works in both browsers.

I'm going to say that there is probably something in page.php that has a syntax error or is malformed. If you take the exact same snippet and crawl something like http://google.com , you get consistent results in all major browsers.

Thanks for all the responses, however it was a stupid error on my part. I was loading up the domain with www. in firefox, but without the www. in IE, hence the difference. I've added a function to strip the www. from the refering domain and now it works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM