2.8 使用其他有用的文件函数

在PHP中,还有许多我们经常使用的有用的文件函数。

2.8.1 查看文件是否存在:file_exists()

如果希望在不打开文件的前提下,检查一个文件是否存在,可以使用file_exists()函数,如下所示:


if(file_exists("$DOCUMENT_ROOT/../orders/orders.txt")){

echo'There are orders waiting to be processed.';

}else{

echo'There are currently no orders.';

}