How to close the file handler SplFileObject?

I work with files in PHP, using SplFileInfo and SplFileObject. But when I try to "re-open" the file, he cries out to me:

SplFileObject::__construct(filemame): failed to open stream: Permission denied 

I think I have to close my file before re-opening, but I can not figure out how to do it. SplFile* have no function close ?!

+6
source share
1 answer

You must install SplFileObject in null , to close the file.

 <?php $fileHandler = new SplFileObject('file.name'); //now file.name is open $fileHandler = null; //file.name is closed. $fileHandler2 = new SplFileObject('file.name'); //file.name is re-opened ?> '); <?php $fileHandler = new SplFileObject('file.name'); //now file.name is open $fileHandler = null; //file.name is closed. $fileHandler2 = new SplFileObject('file.name'); //file.name is re-opened ?> 
+7
source

All Articles