05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If include is specified and is true, fopen( ) tries to locate the file in the current include path.<br />

If any error occurs while attempting to open the file, false is returned.<br />

fpassthru<br />

int fpassthru(int handle)<br />

Outputs the file pointed to by handle and closes the file. The file is output from the current<br />

file pointer location to EOF. If any error occurs, false is returned; if the operation is<br />

successful, true is returned.<br />

fputs<br />

bool fputs(int handle, string string[, int length])<br />

This function is an alias for fwrite( ).<br />

fread<br />

string fread(int handle, int length)<br />

Reads length bytes from the file referenced by handle and returns them as a string. If fewer<br />

than length bytes are available before EOF is reached, the bytes up to EOF are returned.<br />

fscanf<br />

w Open the file for writing. If the file exists, it will be truncated to zero<br />

length; if the file doesn’t already exist, it will be created.<br />

w+ Open the file for reading and writing. If the file exists, it will be truncated<br />

to zero length; if the file doesn’t already exist, it will be created.<br />

The file pointer starts at the beginning of the file.<br />

a Open the file for writing. If the file exists, the file pointer will be at the<br />

end of the file; if the file does not exist, it is created.<br />

a+ Open the file for reading and writing. If the file exists, the file pointer<br />

will be at the end of the file; if the file does not exist, it is created.<br />

mixed fscanf(int handle, string format[, string name1[, ... string nameN]])<br />

Reads data from the file referenced by handle and returns a value from it based on format.<br />

For more information on how to use this function, see sscanf.<br />

If the optional name1 through nameN parameters are not given, the values scanned from the<br />

file are returned as an array; otherwise, they are put into the variables named by name1<br />

through nameN.<br />

402 | Appendix A: Function Reference<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!