The File class is a limited set of helper type methods.
This method’s signature is self explanatory. You supply the full path including filename as the first parameter. The data you want to write as the second parameter. The third parameter is the fopen mode. Fourth parameter is the file permissions for the file, and the fifth parameter is the directory permissions if the file does not already exist.
File::write( $full_path, $data, $mode = 'wb' $f_perm = 0644, $d_perm = 0755 );
Get File Info
Given a full path that includes a filename, returns basic file attributes. Returns FALSE if the file cannot be found.
File::get_info( $file, $single_attr = FALSE );
|filename||Name of file with extension|
|ext||Extension w/o dot|
|realpath||Full path (slashes all going same way)|
|path||Path w/o filename (no trailing slash and slashes not necessarily going same way)|
|size||Size in bytes|
|lastaccess||The time the file was last accessed or used|
|lastmod||The last modified time|
|perms||File’s permissions as an array holding “numeric”, “octal”, and “full” elements|
|readable||If file is readable|
|writable||If file is writable|
Reads the specified directory and builds an array containing the filenames. If second parameter is set to true, the returned array of filenames will include the full path instead of just the file’s name. The third parameter, which is false by default, allows you to retrieve all of the file names from any subdirectories.
File::list_filenames( $source_dir, $include_path = FALSE, $subdirs = FALSE );
Test for directory or file writability using SplFileInfo.
File::writable( $x );
Deletes all files contained in the supplied directory path. If the second parameter is set to TRUE, any directories contained within the supplied base directory will also be deleted. If third parameter is TRUE, the emptied directory will be deleted.
File::delete_dir( $path, $subdirs = FALSE, $remove_dir = FALSE );
Make all the slashes in a path go one way.
File::reslash_path( $path, $slash = '\\' );