0

私の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";
?>
4

1 に答える 1

5

読み込もうとしているファイルは、ローカル ファイルではなくリモート リクエスト経由であるため、そのデータの読み取り方法が大幅に変わります。fread () man page に従って、ファイルをチャンクで読み取る必要があります。または、コードを簡素化するfile_get_contents()を使用してみてください。

$lessonDescription = file_get_contents('http://nova.umuc.edu/~ct386a28/lovej2ee/exercise5/content/vocabulary5.txt');
echo $lessonDescription;
于 2011-04-14T18:14:29.017 に答える