我怎样才能让php文件在zend中用作css?
我参考以下链接,
我正在使用 zend。在我的模板 phtml 文件中,我包括如下
<style type="text/css">
input[type="button"] {
background-image: url("<?php echo SITE_URL; ?>/images/sub_bg-green.jpg");
background-repeat: repeat-x;
border: 1px solid #4B8109;
font-size: 11px;
margin-right: 10px;
padding: 3px 10px;
color:#000;
}
</style>
代码 将给出基本 url。当我包含内部模板页面时,这有效。现在我正在做 w3c 验证,它给出了错误。所以我尝试将所有样式放入
product_details.php
中,并使用以下代码将其包含在 phtml 文件中,
<?php $this->headLink()->appendStylesheet(BASE_URL . 'css/templates/product_details.php'); ?>
当我查看文件的源代码时,我没有得到基本网址,而是得到了类似的结果下面,
<style type="text/css">
input[type="button"] {
background-image: url("SITE_URL/images/sub_bg-green.jpg");
background-repeat: repeat-x;
border: 1px solid #4B8109;
font-size: 11px;
margin-right: 10px;
padding: 3px 10px;
color:#000;
}
</style>
我如何在 css 中包含 php 代码,同时它应该位于 内,以便我们可以实现 w3c 验证。请就此提出建议。
I refer the following link,
I am using zend. In my template phtml file, i include like below,
<style type="text/css">
input[type="button"] {
background-image: url("<?php echo SITE_URL; ?>/images/sub_bg-green.jpg");
background-repeat: repeat-x;
border: 1px solid #4B8109;
font-size: 11px;
margin-right: 10px;
padding: 3px 10px;
color:#000;
}
</style>
code <?php echo SITE_URL; ?>
will give base url. This works when i include inside template page. Now i am working on w3c validation which gives error. so i tried to put all styles in product_details.php
and include it in phtml file by using following code,
<?php $this->headLink()->appendStylesheet(BASE_URL . 'css/templates/product_details.php'); ?>
when i view the source code of file, i did not get the base url, instead i got like below,
<style type="text/css">
input[type="button"] {
background-image: url("SITE_URL/images/sub_bg-green.jpg");
background-repeat: repeat-x;
border: 1px solid #4B8109;
font-size: 11px;
margin-right: 10px;
padding: 3px 10px;
color:#000;
}
</style>
How can i include php code in css and at the same time it should be inside <HEAD>
so that we can achieve w3c validation.Kindly advice on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不只使用 CSS 文件到图像的相对链接,例如
...或者甚至是绝对 URL(如果您的图像始终位于同一位置)
然后只需使用
HeadLink
视图链接 CSS 文件帮手Why not just use relative links from the CSS file to the images, eg
... or even an absolute URL if your images are always in the same place
You then just link the CSS file using the
HeadLink
view helper