本文整理汇总了PHP中Minify::browserCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Minify::browserCache方法的具体用法?PHP Minify::browserCache怎么用?PHP Minify::browserCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Minify
的用法示例。
在下文中一共展示了Minify::browserCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
/**
* Combines, minifies, and outputs the requested files.
*
* Inspects the $_GET array for a 'files' entry containing a comma-separated
* list and uses this as the set of files to be combined and minified.
*/
public static function handleRequest()
{
// 404 if no files were requested.
if (!isset($_GET['files'])) {
header('HTTP/1.0 404 Not Found');
exit;
}
$files = array_map('trim', explode(',', $_GET['files'], MINIFY_MAX_FILES));
// 404 if the $files array is empty for some weird reason.
if (!count($files)) {
header('HTTP/1.0 404 Not Found');
exit;
}
// Determine the content type based on the extension of the first file
// requested.
$type = preg_match('/\\.js$/iD', $files[0]) ? self::TYPE_JS : self::TYPE_CSS;
// Minify and spit out the result.
try {
$minify = new Minify($type, $files);
header("Content-Type: {$type};charset=" . MINIFY_ENCODING);
$minify->browserCache();
echo $minify->combine();
exit;
} catch (MinifyException $e) {
header('HTTP/1.0 404 Not Found');
echo htmlentities($e->getMessage());
exit;
}
}
示例2: handleRequest
/**
* Combines, minifies, and outputs the requested files.
*
* Inspects the $_GET array for a 'files' entry containing a comma-separated
* list and uses this as the set of files to be combined and minified.
*/
function handleRequest()
{
// 404 if no files were requested.
if (!isset($_GET['files'])) {
header('HTTP/1.0 404 Not Found');
exit;
}
$files = array_map('trim', explode(',', $_GET['files'], MINIFY_MAX_FILES));
// 404 if the $files array is empty for some weird reason.
if (!count($files)) {
header('HTTP/1.0 404 Not Found');
exit;
}
// Determine the content type based on the extension of the first file
// requested.
$type = preg_match('/\\.js$/iD', $files[0]) ? TYPE_JS : TYPE_CSS;
// Minify and spit out the result.
$minify = new Minify($type);
$minify->addFile($files);
ob_start("ob_gzhandler");
header("Content-Type: {$type};charset=" . MINIFY_ENCODING);
$minify->browserCache();
echo $minify->combine();
}