本文整理汇总了PHP中Minify::_minify方法的典型用法代码示例。如果您正苦于以下问题:PHP Minify::_minify方法的具体用法?PHP Minify::_minify怎么用?PHP Minify::_minify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Minify
的用法示例。
在下文中一共展示了Minify::_minify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: combine
/**
* Combines and returns the contents of all files that have been added with
* addFile() or via this class's constructor.
*
* If MINIFY_USE_CACHE is true, the content will be returned from the server's
* cache if the cache is up to date; otherwise the new content will be saved
* to the cache for future use.
*
* @param bool $minify minify the combined contents before returning them
* @return string combined file contents
*/
function combine($minify = true)
{
// Return contents from server cache if possible.
if (MINIFY_USE_CACHE) {
if ($cacheResult = $this->serverCache(true)) {
return $cacheResult;
}
}
// Combine contents.
$combined = array();
foreach ($this->files as $file) {
if ($this->type === TYPE_CSS && MINIFY_REWRITE_CSS_URLS) {
// Rewrite relative CSS URLs.
$combined[] = Minify::rewriteCSSUrls(file_get_contents($file), dirname($file));
} else {
$combined[] = file_get_contents($file);
}
}
$combined = $minify ? Minify::_minify(implode("\n", $combined), $this->type) : implode("\n", $combined);
// Save combined contents to the cache.
if (MINIFY_USE_CACHE) {
$cacheFile = MINIFY_CACHE_DIR . '/minify_' . $this->getHash();
file_put_contents($cacheFile, $combined, LOCK_EX);
}
return $combined;
}