3 # This program is in the public domain within the United States. Additionally,
4 # we waive copyright and related rights in the work worldwide through the CC0
5 # 1.0 Universal public domain dedication, which can be found at
6 # http://creativecommons.org/publicdomain/zero/1.0/
9 # This exists because file_get_contents() is not documented well. (It says that
10 # the second parameter is optional, but does not specify the default behavior.)
11 function read_whole_file($name) {
12 $fd = fopen($name, 'r');
14 die("Failed to read file: '$name'");
16 $file_data = fread($fd, filesize($name));
21 # This exists because file_put_contents() is not included in PHP4.
22 function write_whole_file($name, $data) {
23 $fd = fopen($name, 'w');
25 die("Failed to read file: '$name'");
31 function read_whole_file_or_false($name) {
32 if(!file_exists($name)) {
35 return read_whole_file($name);