每当用户进入这样的页面时,我就会从文件中生成CSS:
<?php
header("Content-type: text/css");
$styles = array(
'default',
'reset',
'notifybar',
'jqui'
);
if (isset($_GET['page'])) {
if (file_exists('styles/' . trim($_GET['page']) . '.css'))
$styles [] = $_GET['page'];
switch ($_GET['page']) {
case "main":
$styles [] = "treeview";
$styles [] = "buttons";
$styles [] = "wmd";
$styles [] = "qa";
$styles [] = "pretify";
$styles [] = "code";
$styles [] = "msgBoxes";
break;
case "payments":
$styles [] = "tables";
break;
}
}
foreach ($styles as $style) {
include 'styles/' . $style . '.css';
}
?>
HTML就像这样获取CSS
<link rel="stylesheet" href="design/css.php?page=<?= $pgdata['token'] ?>" type="text/css" media="screen" />
我有两个问题:
答案 0 :(得分:0)
您可以使用PHP5库minify。
它确实缩小,缓存和连接JS和CSS文件,因此它可以是解决方案。 以下是有关如何实施它的演练:http://www.mrclay.org/2008/09/19/minify-21-on-mrclayorg/