Class File

Description

File class to wrap around the file functions

Example:


1 $file =& new File('/home/user/file');
2 if ($file->is_readable()) {
3 $contents = $file->get_contents();
4 }

See test_File.php file for examples.

Located in Program_Root/File.php (line 37)


	
			
Method Summary
void File (string $file)
string basename ([string $suffix = null])
string dirname ()
bool exists ()
string filename ()
resource fopen (string $mode)
string get_contents ()
bool is_readable ()
bool is_writable ()
bool is_writeable ()
resource open_for_reading ()
resource open_for_writing ()
string realpath ()
int size ()
bool unlink ()
Methods
Constructor File (line 50)

Constructor

void File (string $file)
  • string $file
basename (line 107)

Basename

Returns the base name of the file. If the filename ends in suffix this will also be cut off. Example:


1 $file =& new File('/home/httpd/html/index.php');
2 $basename = $file->basename(); // $basename is set to "index.php"
3 $basename = $file->basename('.php');
Note: The suffix parameter was added in PHP 4.1.0.

string basename ([string $suffix = null])
  • string $suffix:

    if filename ends in $suffix this will be cut off.

dirname (line 129)

Directory name

Returns the name of the directory. On Windows, both slash (/) and backslash (\) are used as path separator character. In other environments, it is the forward slash (/).

Example:


1 $file =& new File('/etc/passwd');
2 $dirname = $file->dirname();

string dirname ()
exists (line 87)

Exists

bool exists ()
filename (line 192)

File name

string filename ()
fopen (line 203)

Open - see fopen() manual entry

resource fopen (string $mode)
  • string $mode
get_contents (line 161)

Get contents - reads entire file into a string

string get_contents ()
get_contents_as_array (line 174)

Get contents as array - reads entire file into an array

array get_contents_as_array ()
is_readable (line 59)

Is readable

bool is_readable ()
is_writable (line 68)

Is writable

bool is_writable ()
is_writeable (line 78)

Is writeable

bool is_writeable ()
open_for_reading (line 213)

Open for reading

resource open_for_reading ()
open_for_writing (line 223)

Open for writing

resource open_for_writing ()
realpath (line 142)

Real path

Expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input path and return the canonicalized absolute pathname.

string realpath ()
size (line 183)

Size - gets file size

int size ()
unlink (line 152)

Unlink - deletes file Returns TRUE on success or FALSE on failure.

bool unlink ()

Documention generated on Wed, 16 Jul 2003 01:03:08 +0100 by phpDocumentor 1.2.0