Introduction

Introduction – Introduction to the File class

Description

File provides an easy interface to PHP's builtin file and directory functions, plus some functions to deal with paths.

Example

Using File

<?php
require_once 'File.php';

$file "/home/tal/example.txt";

//Echo the whole file
echo File::readAll($file);

//Now use a different approach
$fp = new File();

//Write a single line to the file, using a Macintosh EOL character and
//truncating the file before writing to it
$fp->writeLine($file"This is a single line"FILE_MODE_WRITE"\r");

//strip leading and trailing separators from the file path
echo $fp->stripLeadingSeparators($file);
echo 
$fp->stripTrailingSeparators($file);

?>
File (Previous) Predefined Constants (Next)
Last updated: Tue, 29 Jul 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.