简体   繁体   中英

CodeIgniter code being commented out by HTML

I am using CodeIgniter 2.1.4 with PHP 5.5.12 on my local machine.

My PHP code seems to be commented out in HTML automatically.

Below is a snippet of my code:-

<? if($this->agent->browser()=='MSIE'){ ?>
    <img class="bg" src="<?=base_url()?>assets/img/bg.jpg" alt="Login Background" />
<? } ?>

When I try to inspect it in Chrome, it shows the below:-

<!--? if($this--->
agent-&gt;browser()=='MSIE'){ ?&gt;
<img class="bg" src="http://localhost/abc/assets/img/bg.jpg" alt="Login Background">
<!--? } ?-->

This is just one of a few places that was automatically commented out. I know the code works because I have the same code working well on a production server. It is just happening on my local machine.

Use long open tags.

<?php if($this->agent->browser()=='MSIE'){ ?>

Or if for some reason cannot do that then enable short-open-tag setting.

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