Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用txt文件显示与php的链接_Php - Fatal编程技术网

使用txt文件显示与php的链接

使用txt文件显示与php的链接,php,Php,我正在尝试使用php和txt文件显示链接 我的文本文件(Text.txt) 到目前为止我的php代码(index.php) 从文本文件读取 运行index.php时不断出现的错误。这是浏览器显示的内容; 您可以使用删除空格和新行字符,然后它应该可以正常工作,我刚刚尝试过: (另外,确保txt文件没有utf-8 BOM) 从文本文件读取 如果浏览器向您提供您提到的输出,这意味着您的计算机中尚未安装PHP。请下载并安装以执行PHP脚本。但是,如果已安装PHP,则您没有使用服务器地址,即http

我正在尝试使用php和txt文件显示链接

我的文本文件(Text.txt)

到目前为止我的php代码(index.php)


从文本文件读取
运行index.php时不断出现的错误。这是浏览器显示的内容;

您可以使用删除空格和新行字符,然后它应该可以正常工作,我刚刚尝试过:

(另外,确保txt文件没有utf-8 BOM)


从文本文件读取

如果浏览器向您提供您提到的输出,这意味着您的计算机中尚未安装PHP。请下载并安装以执行PHP脚本。

但是,如果已安装PHP,则您没有使用服务器地址,即
http://localhost/APP/
<代码>file:///C:/server/www/APP/将不会执行php脚本。

我认为您直接在浏览器中打开了index.php。此代码中没有错误。试着以正确的方式运行它。也就是说(localhost/yourDirectory/index.php)

看起来好像没有安装php(或者由于其他原因没有处理文件),您会看到纯HTML解决方案是什么?请帮忙,我帮了。现在我从
file:///C:/wamp/www/
但我仍然收到相同的错误。更新-正常运行,谢谢!是的。请参见下文@devaldcool的评论。它仍然给出相同的错误。
Spiderman, www.spiderman.com
See No Evil, www.seenoevil.com 
<html>
<head>
<title>Reading from text files</title>

</head>
<body>

<?php
$f = fopen("text.txt", "r");

// Read line by line until end of file
while (!feof($f)) { 

// Make an array using comma as delimiter
   $arrM = explode(",",fgets($f)); 

// Write links (get the data in the array)
   echo "<li><a href='http://" . $arrM[1] . "'>" . $arrM[0]. "</a></li>"; 

}

fclose($f);
?>

</body>
</html>
<html>
<head>
<title>Reading from text files</title>

</head>
<body>

<?php
$f = fopen("text.txt", "r");

// Read line by line until end of file
while (!feof($f)) { 

// Make an array using comma as delimiter
   $arrM = explode(",",fgets($f)); 

// Write links (get the data in the array)
   echo "<li><a href='http://" . trim($arrM[1]) . "'>" . trim($arrM[0]). "</a></li>"; 

}

fclose($f);
?>

</body>
</html>