问题描述
我正在尝试使用fgets()从另一个PHP文件中读取a.php文件,并且
显示其内容。由于a.php以<?开头浏览器IE6没有显示
任何东西,虽然我可以看到View-Source中的所有内容。
我试图用<?跳过这行使用以下代码:
@ $ fp = fopen(" a.php"," r");
while(!feof($ fp))
{
$ line = fgets($ fp);
if(!$ line =="<?" ;)
{
echo $ line;
}
else
{
echo" w";
}
然而它不断输出w对于a.php的每一行。
即使我将条件反转为if(!$ line =="<?")
这也不会改变好像被fgets($ fp)所回复的东西无法与<?相比。
我试图将该行的末尾添加到模式中(!$ line ==" ;<?\ n")或
($ line =="<?\ n") - 结果相同。
什么是我做错了吗?
I am trying to read a.php file from another PHP file using fgets() and
display its contents. As a.php starts with <? the browser IE6 does not show
anything, although I can see all the contents in View-Source.
I tried to skip the line with <? using the following code:
@ $fp=fopen("a.php","r");
while (!feof($fp))
{
$line=fgets($fp);
if (!$line=="<?")
{
echo $line;
}
else
{
echo "w";
}
However it keeps outputting "w" for every line of a.php.
This does not change even is I reverse the condition to if (!$line=="<?")
as if whatever is returened by fgets($fp) cannot be compared to "<?".
I tried to add the end of the line to the pattern (!$line=="<?\n") or
($line=="<?\n") - same result.
What is that I am doing wrong?
这篇关于阅读"<?"来自一个PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!