简体   繁体   English

PHP的-为什么我的数据不会显示在Firefox

[英]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. 我在index.php页面中使用以下代码来显示另一域中一个页面的内容。 However, it works fine in IE, but when I load the page in Firefox, its missing php data. 但是,它在IE中工作正常,但是当我在Firefox中加载页面时,缺少的php数据。

Am I doing something wrong or does firefox not allow this? 我是在做错什么,还是Firefox不允许这样做? 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. 在许多情况下,此类问题是由浏览器缓存引起的,尤其是在Firefox中,我也面临类似的情况。 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). 删除服务器上的文件,上传此代码(它只是一个更清晰的解决方案,不需要allow_url_fopen ,这很危险)。

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']; ?> <? echo $_SERVER['HTTP_HOST']; ?> <? echo $_SERVER['HTTP_HOST']; ?> and check if it works in both browsers. <? echo $_SERVER['HTTP_HOST']; ?>并检查它是否在两种浏览器中均适用。

I'm going to say that there is probably something in page.php that has a syntax error or is malformed. 我要说的是,page.php中可能存在语法错误或格式错误的内容。 If you take the exact same snippet and crawl something like http://google.com , you get consistent results in all major browsers. 如果您使用完全相同的代码段并抓取类似http://google.com之类的内容 ,则在所有主流浏览器中都能获得一致的结果。

Thanks for all the responses, however it was a stupid error on my part. 感谢所有答复,但这对我来说是一个愚蠢的错误。 I was loading up the domain with www. 我正在用www加载域。 in firefox, but without the www. 在Firefox中,但没有www。 in IE, hence the difference. 在IE中,因此有所不同。 I've added a function to strip the www. 我添加了剥离www的功能。 from the refering domain and now it works fine. 从引用域,现在可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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