From 1a9b9a0143d0536149e5b543bbf033ed2f82e087 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Tue, 11 Jul 2006 17:42:21 +0000 Subject: [PATCH] Emulate file_put_contents() under PHP 4.3.x --- lib/moodlelib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b823c5d809..0ca8b10344 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6766,6 +6766,25 @@ function cleanremoteaddr($addr) { return array_pop($goodmatches); } +/** + * file_put_contents is only supported by php 5.0 and higher + * so if it is not predefined, define it here + * + * @param $file full path of the file to write + * @param $contents contents to be sent + * @return number of bytes written (false on error) + */ +if(!function_exists('file_put_contents')) { + function file_put_contents($file, $contents) { + $result = false; + if ($f = fopen($file, 'w')) { + $result = fwrite($f, $contents); + fclose($f); + } + return $result; + } +} + /** * html_entity_decode is only supported by php 4.3.0 and higher * so if it is not predefined, define it here -- 2.39.5