像加载IMG一样从PHP加载CSS


Load CSS from PHP like loading IMG

我可以使用下面的代码来加载IMG文件:

<img src="http://www.www.com/image-name.php"/>

现在,我想知道如何从外部php加载CSS ?

<link rel='stylesheet' href='http://www.www.com/main-css-file.php' />

的原因是CSS将在主题文件夹与htaccess文件完全拒绝。

感谢任何帮助!

非常简单。

<?php header('Content-type: application/pdf'); ?>
h1 {
    font-size: 40px;
}
h2 {
    font-size: 30px;
}
p {
    font-size: 14p
}

您需要在返回数据之前将Content-Type标头设置为text/css:

<?php
  header('Content-Type: text/css; charset=utf-8');
  $color = '#d0e4fe';
?>
body {
    background-color: <?php echo $color ?>;
}