somejkuser
somejkuser

Reputation: 9040

SplFileInfo,file_put_contents, and create file

Is there an equivalent to file_put_contents with SplFileInfo. I see SplFileInfo::fwrite but does that account for appending and locking?

Also would about creating a file?

Upvotes: 1

Views: 1025

Answers (1)

u_mulder
u_mulder

Reputation: 54831

First of all, SplFileInfo has no fwrite method. But SplFileObject does. Second - there's no equivalent to file_put_contents method both in SplFileInfo and SplFileObject. But you can extend SplFileObject and create it (though I don't know what for).

For example:

class MySplFileObject extends SplFileObject {

    public function file_put_contents($contents) 
    {
        $this->fwrite($contents);
    }
}

Upvotes: 1

Related Questions