简体   繁体   中英

css is auto-commenting php code?

I have an issue with 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.

What could be the issue?

the CSS code I only defined some margins with:

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

This has nothing to do with CSS; your PHP code shouldn't ever reach the browser in the first place.

Make sure you have PHP installed and your web server is set up to interpret PHP scripts. Right now, it appears to be treating them as 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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