]> git.mjollnir.org Git - moodle.git/commitdiff
Emulate file_put_contents() under PHP 4.3.x
authorstronk7 <stronk7>
Tue, 11 Jul 2006 17:42:21 +0000 (17:42 +0000)
committerstronk7 <stronk7>
Tue, 11 Jul 2006 17:42:21 +0000 (17:42 +0000)
lib/moodlelib.php

index b823c5d8095db6a1d89fa6c561aa87b47ddd54a8..0ca8b10344b69d447cfe0e4b0f528ae3f67289f7 100644 (file)
@@ -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