. # This exists because file_get_contents() is not documented well. (It says that # the second parameter is optional, but does not specify the default behavior.) function read_whole_file($name) { $fd = fopen($name, 'r'); if($fd === false) { die("Failed to read file: '$name'"); } $file_data = fread($fd, filesize($name)); fclose($fd); return $file_data; } # This exists because file_put_contents() is not included in PHP4. function write_whole_file($name, $data) { $fd = fopen($name, 'w'); if($fd === false) { die("Failed to read file: '$name'"); } fwrite($fd, $data); fclose($fd); } function read_whole_file_or_false($name) { if(!file_exists($name)) { return false; } return read_whole_file($name); } ?>