2022年8月19日10:26:45
$fileName = 'robots.txt';
//开启句柄
$file1 = new SplFileInfo($fileName);
echo $file1->getFilename();
//关闭句柄
$file = null;
//再次打开
$file2 = new SplFileInfo($fileName);
echo $file2->getFilename();
可能出现:failed to open stream: Permission denied
fopen fclose是相对的,但是SplFileInfo SplFileObject 没有专门的关闭句柄的方法
参考:https://www.php.net/manual/en/class.splfileobject.php#113149
标签:SplFileInfo,句柄,fileName,SplFileObject,关闭,php From: https://www.cnblogs.com/zx-admin/p/16601169.html