The below code snippet gets the contents of a file into a string using php. fread() reads up to length bytes from the file pointer referenced by handle. Reading stops when length bytes have been read.
// get contents of a file into a string $filename = '/path/to/file'; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle);
- Login or register to post comments