Enable PHP short open tags via .htaccess

2019-02-04 02:23发布

I’m currently running through a tutorial for a CMS system which unfortunately uses short open tags.

I’ve confirmed that my host will not allow these in their PHP config, but that they run PHP in Apache mode (as opposed to CGI). To the best of my knowledge, this should then allow me to set the short_open_tag flag to on in an .htaccess file.

However, this appears to not be working. In the root directory, I've created an .htaccess file with just the following line, but the short open tags are still being ignored.

php_flag short_open_tag on

Am I doing something wrong? If not, can anyone suggest why it may not be working? Thanks.

Note: Someone has marked this question as being answered somewhere else. Not only does the question identified not have an accepted answer, it's based around and PHP config running in CGI mode, not Apache mode.

2条回答
疯言疯语
2楼-- · 2019-02-04 02:46

For .htaccess it should be php_value short_open_tag 1 For an ini file it's short_open_tag=On.

If it doesn't work in the .htaccess then you could try to add you own php.ini in you site root. That said it's unlikely to work.

Simply put the server admin could have completely disabled this functionality and no matter what you add you will not be able to activate it. It's best you ask your host and save yourself the pain.

查看更多
We Are One
3楼-- · 2019-02-04 03:00

Try this

 <IfModule mod_php5.c>
   php_value short_open_tag 1
 </IfModule>

This would solve the problem

查看更多
登录 后发表回答