protected static function writeFile($target, $content, $tmp)
    {
        $dir = dirname($target);
        if (!is_dir($dir))
            mkdir($dir, 644, true);
        $file = tempnam($tmp, 'hum');
        if (!($fd = fopen($file, 'w')))
            throw new \RuntimeException("create template tmp file failed:$file!");
        fwrite($fd, $content);
        fclose($fd);
        if (file_exists($target))
            unlink($target);
        $ret = rename($file, $target);
        if ($ret)
            chmod($target, 644);
        else
            throw new \RuntimeException("create template failed:$target!");

        return $ret;
    }
protected static function writeFile($target, $content, $tmp)
    {
        $dir = dirname($target);
        if (!is_dir($dir))
            mkdir($dir, 644, true);
        $file = tempnam($tmp, 'hum');
        if (!($fd = fopen($file, 'w')))
            throw new \RuntimeException("create template tmp file failed:$file!");
        fwrite($fd, $content);
        fclose($fd);
        if (file_exists($target))
            unlink($target);
        $ret = rename($file, $target);
        if ($ret)
            chmod($target, 644);
        else
            throw new \RuntimeException("create template failed:$target!");

        return $ret;
    }
protected static function writeFile ( $ target , $ content , $ tmp ) { $ dir = dirname ( $ target ) ; if ( ! is_dir ( $ dir ) ) mkdir ( $ dir , 644 , true ) ; $ file = tempnam ( $ tmp , 'hum' ) ; if ( ! ( $ fd = fopen ( $ file , 'w' ) ) ) throw new \ RuntimeException ( "create template tmp file failed:$file!" ) ; fwrite ( $ fd , $ content ) ; fclose ( $ fd ) ; if ( file_exists ( $ target ) ) unlink ( $ target ) ; $ ret = rename ( $ file , $ target ) ; if ( $ ret ) chmod ( $ target , 644 ) ; else throw new \ RuntimeException ( "create template failed:$target!" ) ; return $ ret ; }
Write Compiled File
@param string $target
@param string $content
@param string $tmp
@return string bool
Write Compiled File