PHP在循环中读取文件

Spe*_*May 0 php text loops file-get-contents

我在php循环中读取文本文件时遇到问题.这是我的代码的一个更简单的例子,我知道我应该检查它是否存在我的较长版本中存在的文件,但无论我做什么,这都不会读取我的文本文件.PHP警告说文本文件是空的,但它们不是.PHP正在写这个<br />.

for ($i=1; $i<=5; $i++)
{
   $myFile = "$i.txt";
   $readfile = file_get_contents($myfile);
   echo "$readfile <br />";
}
Run Code Online (Sandbox Code Playgroud)

fir*_*ire 5

你的传入$myfile,file_get_contents但它被称为$myFile上面(区分大小写)