SplFileObject vs fopen in PHP

Viewed 8894

What are the pros and cons of using fopen as opposed to SplFileObject in PHP?

From what I see, SplFileObject throws exceptions where applicable which makes this convenient when using try...catch for error handling. Apart from this, are there any other reasons to recommend one over the other?

(Bonus: Why is it called SplFileObject? What does Spl stand for? Why not simply FileObject?)

Update: One limitation of the SplFileObject is that it does not (yet) have a close member function. In some scenarios this can be a problem (Example: Unlink and SplFileObject).

3 Answers
Related