Почему не работает мой метод filesize()?Мой путь работает для методов fread() и file(), но он не будет подтверждать путь в filesize().Почему бы и нет?Каким должен быть мой правильный путь?
filesize()
fread()
file()
<?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"; ?>
Поскольку файл, который вы пытаетесь прочитать, создается с помощью удаленного запроса, а не локального файла, это существенно меняет способ чтения этих данных.На странице справочника fread () необходимо прочитать файл кусками.Или попробуйте использовать file_get_contents () , что должно упростить ваш код:
$lessonDescription = file_get_contents('http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt'); echo $lessonDescription;