phplinter\Path::write_file PHP Method

write_file() public static method

----------------------------------------------------------------------+
public static write_file ( $file, $content, $mode = 'w', $perm = 436 ) : Bool
$file String
$content String
$mode String [r,r+,w,w+,a,a+,x,x+][bt]
$perm Oct
return Bool ----------------------------------------------------------------------+
    public static function write_file($file, $content, $mode = 'w', $perm = 0664)
    {
        if ($fp = fopen($file, $mode)) {
            fwrite($fp, $content);
            fclose($fp);
            chmod($file, $perm);
            return true;
        }
        return false;
    }

Usage Example

Example #1
0
 /**
 ----------------------------------------------------------------------+
 * @desc 	FIXME
 ----------------------------------------------------------------------+
 */
 protected function write($filename, $content)
 {
     if (!$this->dry_run) {
         if (!\phplinter\Path::write_file($filename, $content)) {
             die("Unable to create '{$filename}'...");
         }
     }
     if ($this->config->check(OPT_VERBOSE)) {
         echo "Wrote to file `{$filename}`\n";
     }
 }