读取文本文件内容并在表格中显示(PHP) [英] Read textfile content and display in table (PHP)

查看:321
本文介绍了读取文本文件内容并在表格中显示(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在这里学习PHP。我有一个PHP页面。另一方面,我在相同的运行文件夹上放置了welcome.txt。我想阅读所有代码行包括breakline和显示在表上但我得到错误。下面是我在PHP中的代码:



Hi all,

I'm just learning PHP here. I have a page in PHP. On other side, I have place a welcome.txt on same running folder. I want to read all line of code include the breakline and display on table but I got error. Below are my code in PHP:

<td width="600" bgcolor="#213A3F">
<?php
$file = "/content/welcome.txt";
$f = fopen($file, "r");
while ( $line = fgets($f, 1000) ) {
print $line;
}
?>
</td>







但是当我运行页面时显示错误:






But and error display when I running my page:

Warning: fopen(/content/welcome.txt): failed to open stream: No such file or directory in C:\xampp\htdocs\solaire\home.php on line 34

Warning: fgets() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\solaire\home.php on line 35





有人可以在这里找到我的问题并告诉我我做错了什么吗?我需要指导。



另外,如果有人能给我链接网站PHP代码,CSS和类似学习网站开发的东西,我很感激。



Can someone please find my problem here and tell me what I've done wrong? I need guidance.

Also, I appreciate if someone can give me link website for PHP code, CSS and something like learning website development.

推荐答案

file = / content / welcome.txt;
file = "/content/welcome.txt";


f = fopen(
f = fopen(


file, r);
while
file, "r"); while (


这篇关于读取文本文件内容并在表格中显示(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆