of the file. This is applicable for all
Monday, November 20th, 2006of the file. This is applicable for all read calls that take file handle fpas an argument. The following code reads the entire file: if (!($fp = fopen(”a.txt”, “r”))( { printf(”Could not open file a.txt”); } else { while ($buffer = fread($fp, 100)) { // Process the read data } } string fgetc(int fp) The function fgetc() is used to read a single character from the open file. It returns a one character string at the current position of the file handle and increments the current position by one. It returns false(empty string) on reaching the end of the file: string fgets(int fp, int length) The function fgets() reads and returns a string, starting at the current position of the file handle, of up to “length-1″ bytes. The reading ends when length 1 bytes have been read, or a new line or end of file is reached. As a side effect of this call the current position of the file handle points to the next unread character: string fgetss(int fp, int length [,string allowable_tags]) The function fgetss() is identical to fgets(), except that any HTML and PHP tags are stripped from the string. The argument allowable_tags can be used to specify the list of comma separated tags, which should not be stripped. Note that the tags are still counted towards the length of the string: array file(string filename [,int use_include_path]) The function file() reads the contents of file filenameinto an array. The function returns an array, where each element of the array corresponds to a line, with the end of line (line feed and carriage return) character still attached, in the file on success. The file() function should be used to read small files only. It should never be used to read big files, as it may unnecessarily increase the memory footprint of the PHP interpreter. The following code reads the contents of a.txtand outputs it as an HTML document:
Hint: This post is supported by Gama besplatan domen provider