简体   繁体   English

CSS是自动注释PHP代码?

[英]css is auto-commenting php code?

I have an issue with CSS.. 我的CSS有问题。

By using the following code: 通过使用以下代码:

<div class="divisor">
<p>
<?php if (isset($_SESSION['invalid'])) { echo 'test'; } ?>
</p>
</div>

The result on the generated page in browser is the following: 在浏览器中生成的页面上的结果如下:

<!--?php if (isset($_SESSION['invalid'])) { echo 'test'; } ?-->

Practically, the browser is auto-commenting out my php code, with the result of skipping the whole code from executing it. 实际上,浏览器会自动注释我的php代码,从而导致跳过执行整个代码的结果。

What could be the issue? 可能是什么问题?

the CSS code I only defined some margins with: CSS代码中,我仅使用以下定义了边距:

.divisor p {
margin-top: 5px;
margin-left: 5px;
}

This has nothing to do with CSS; 这与CSS无关。 your PHP code shouldn't ever reach the browser in the first place. 您的PHP代码永远都不会到达浏览器。

Make sure you have PHP installed and your web server is set up to interpret PHP scripts. 确保已安装PHP,并且已将Web服务器设置为解释PHP脚本。 Right now, it appears to be treating them as HTML. 现在,似乎将它们视为HTML。

Note that you must access this page through a server; 请注意,您必须通过服务器访问此页面。 it's not enough just to open a file on your local machine in a browser. 仅在浏览器中打开本地计算机上的文件还不够。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM