本文整理匯總了PHP中app\File::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP File::write方法的具體用法?PHP File::write怎麽用?PHP File::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\File
的用法示例。
在下文中一共展示了File::write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cache
/**
* Caches a file for the current unique URL using the data type as part of its id.
*
* @access private
* @param string $etag The current etag, will be replaced if new etag is generated
* @return App\File
*/
private function cache(&$etag)
{
$cache_id = $this->generateCacheId();
$data_hash = md5($this->view);
if (self::etag($cache_id, $etag, TRUE) && $etag == $data_hash) {
return NULL;
}
self::etag($cache_id, $etag = $data_hash);
if (!$this->type) {
$extension = pathinfo($this->url->getPath(), PATHINFO_EXTENSION);
$temp_file = $cache_id . ($extension ? '.' . $extension : NULL);
$temp_file = new App\File(self::$cacheDirectory . DS . $temp_file);
$temp_file->write($this->view);
$this->type = $temp_file->getMimeType();
if (!$extension && $this->type == 'text/plain') {
$this->type = self::$defaultType;
}
$cache_id = $this->generateCacheId();
$cache_file = $temp_file->rename($cache_id, TRUE);
self::etag($cache_id, $data_hash);
} else {
$cache_file = new App\File(self::$cacheDirectory . DS . $cache_id);
}
return $cache_file;
}
示例2: write
/**
*
*/
private function write()
{
if (!$this->outputFile) {
throw new Flourish\ProgrammerException('Could not write scaffolded code, not output file specified');
}
$file = new App\File($this->outputFile);
$file->write($this->code);
}