Reading files

Open and immediately output the file

readfile(file) ;

 

Open and assign file as a string

file_get_contents(file) ;

 

Open and assign file into array

file(file) ;

 

Read single line from opened file

fgets(file, [length]) ; //note, [length] is optional

*note feof(); tests for EOF from the file handle

*If no length specified will keep reading until end of line, or \n

 

Read opened file

fread(file, length) ; //note, length is mandatory

 

Leave a Reply