也许我们可以这样
<?php
/**
* Created by PhpStorm.
* User: leifeng
* Date: 2018/8/8
* Time: 15:52
*/
//自动创建test文件
$document_root = $_SERVER['DOCUMENT_ROOT'];
echo $document_root.'<br>';
$fp = fopen("$document_root/test.txt",'wb');
$str = "this is a test file.\r\n";
fwrite($fp,$str,strlen($str));
fclose($fp);
$fp = fopen("$document_root/test.txt",'rb');
while (!feof($fp)){
$order = fgets($fp);//读取一行
echo "$order";
}
fclose($fp);