How to enable PHP short tags?

2018-12-31 00:26发布

I have a web application on a Linux server which starts with <?

I needed to copy this application to a windows environment and everything is working fine except that an SQL statement is being rendered differently. I don't know if this has to do with the script beginning with <?php instead of <? because I don't know from where to enable the <? from the PHP.ini so I changed it to <?php

I know that these 2 statements are supposed to mean the same but I need to test it with <? in order to ensure that the application is exactly the same. This way I can eliminate another possibility.

Thanks

18条回答
栀子花@的思念
2楼-- · 2018-12-31 00:48
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
;short_open_tag=Off   <--Comment this out
; XAMPP for Linux is currently old fashioned
short_open_tag = On   <--Uncomment this
查看更多
查无此人
3楼-- · 2018-12-31 00:49

you need to turn on short_open_tags.

short_open_tag = On
查看更多
忆尘夕之涩
4楼-- · 2018-12-31 00:49

In CentOS 6(tested on Centos 7 too) you can't set short_open_tag in /etc/php.ini for php-fpm. You will have error:

ERROR: [/etc/php.ini:159] unknown entry 'short_open_tag'
ERROR: Unable to include /etc/php.ini from /etc/php-fpm.conf at line 159
ERROR: failed to load configuration file '/etc/php-fpm.conf'
ERROR: FPM initialization failed

You must edit config for your site, which can found in /etc/php-fpm.d/www.conf And write at end of file:

php_value[short_open_tag] =  On
查看更多
余生请多指教
5楼-- · 2018-12-31 00:53

Set

short_open_tag=On

in php.ini

And restart your Apache server.

查看更多
不流泪的眼
6楼-- · 2018-12-31 00:55

If you are using xampp in windows then please do following

  1. Open XAMPP control panel.
  2. Click on CONFIG button.
  3. Go to PHP (php.ini) option.

Find short_open_tag using ctrl+f utility

You will found ;short_open_tag

kindly remove the semicolon (;) from line.

and keep it as short_open_tag = on

Finally, restart your Apache server

查看更多
几人难应
7楼-- · 2018-12-31 00:57
 short_open_tag = On

in php.ini And restart your Apache Server.

查看更多
登录 后发表回答