previousFile::writeChar() (Previous) (Next) File_Findnext

View this page in Last updated: Sun, 18 Oct 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

File::writeLine()

File::writeLine() – writes a single line to a file

Synopsis

require_once 'File.php';

mixed File::writeLine ( string $filename , string $line , string $mode = FILE_MODE_APPEND , string $crlf = "\n" , mixed $lock = false )

Description

Writes a single line, appending a linefeed by default.

Parameter

  • $filename - Name of file to write to

  • $line - Line of data to be written to file

  • $mode - Write mode, can be either FILE_MODE_WRITE or FILE_MODE_APPEND. Defaults to appending.

  • $crlf - Carriage return / line feed your system is using. Defaults to LF (\n), but can be set to anything. On Unix, \n is used, on Windows \r\n and Mac OS uses \r.

  • $lock - If the file shall be locked

Return value

PEAR_Error when an error occured, number of bytes written when all went well (crlf included).

Example

Using File::writeLine()

<?php
require_once 'File.php';

$e File::writeLine('test.txt'str_repeat("0123456789"1000));

if (
PEAR::isError($e)) {
    echo 
'Could not write to file : ' $e->getMessage();
} else {
    echo 
"Successfully wrote to file test.txt\n";
}
?>
previousFile::writeChar() (Previous) (Next) File_Findnext

Download Documentation Last updated: Sun, 18 Oct 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.