为什么我的 filesize() 方法不起作用?
为什么我的 filesize()
方法不起作用?我的路径适用于 fread()
和 file()
方法,但它不会确认 filesize()
上的路径。为什么不呢?我的正确道路应该是什么?
<?php
$strLessonDescription = fopen("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/lesson5.txt", "r")
or die ("Error - lesson5.txt cannot be opened");
$lessonDescription = fread($strLessonDescription,
filesize("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt"));
fclose($strLessonDescription);
echo $lessonDescription;
$arrLessonVocabulary = array();
$arrLessonVocabulary = file("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt");
if (arrLessonVocabulary == NULL)
print "Error - vocabulary5.txt cannot be opened";
?>
Why wont my filesize()
method work? My path works for the fread()
and file()
methods, but it wont acknowledge the path on filesize()
. Why not? What should my correct path be?
<?php
$strLessonDescription = fopen("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/lesson5.txt", "r")
or die ("Error - lesson5.txt cannot be opened");
$lessonDescription = fread($strLessonDescription,
filesize("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt"));
fclose($strLessonDescription);
echo $lessonDescription;
$arrLessonVocabulary = array();
$arrLessonVocabulary = file("http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt");
if (arrLessonVocabulary == NULL)
print "Error - vocabulary5.txt cannot be opened";
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您尝试读取的文件是通过远程请求而不是本地文件,因此它会显着改变您读取该数据的方式。根据 fread() 手册页,您需要分块读取文件。或者,尝试使用 file_get_contents() 这应该简化你的代码:
Since the file you're trying to read is via a remote request, rather than local file, it significantly changes how you want to read that data. Per the fread() manual page, you need to read the file in chunks. Alternatively, try using file_get_contents() which should simplify your code: