Skip to content
Browse files

Oops, file_put_contents is PHP 5 only

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Page2/trunk@274635 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 1a506da commit cf4d493b6d189ef4ca43acd9d65d1d66be9f25d4 @CloCkWeRX CloCkWeRX committed
Showing with 9 additions and 3 deletions.
  1. +9 −3 Page2.php
View
12 Page2.php
@@ -1630,10 +1630,16 @@ function toHtml()
*/
function toFile($filename)
{
- file_put_contents($filename, $this->toHtml());
-
+ if (function_exists('file_put_contents')) {
+ file_put_contents($filename, $this->toHtml());
+ } else {
+ $file = fopen($filename,'wb');
+ fwrite($file, $this->toHtml());
+ fclose($file);
+ }
+
if (!file_exists($filename)){
- PEAR::raiseError("HTML_Page::toFile() error: Failed to write to $filename",0,PEAR_ERROR_TRIGGER);
+ PEAR::raiseError("HTML_Page::toFile() error: Failed to write to $filename", 0, PEAR_ERROR_TRIGGER);
}
} // end func toFile

0 comments on commit cf4d493

Please sign in to comment.
Something went wrong with that request. Please try again.