开发者

PHP shorthand isn't working on new server? [duplicate]

This question already has answers here: Closed 11 years ago. 开发者_Go百科

Possible Duplicate:

<? ?> tags not working in php 5.3.1

I usually use shorthand syntax

 <?="hello";?>

instead of

 <?php echo "hello";?>

I created a development server and installed same version of php but shorthand method doesn't work, why? how can I fix it?

I would ask this on the server site, but this is related to a php setting or something I believe.

I'm running linux fedora 14


You need to enable the short_open_tag option in the configuration file php.ini (probably in /etc/). As you have discovered, short tags are disabled by default.

Edit: and yes, as @Sebastian P points out, this has been asked before.


Find your php.ini file in the apache directory and change short_open_tag = On


You probably need to enable short tags, which is an ini setting as you supposed.

You should note that short tags are regarded by some as a bad idea (myself included). I know they are handy and thus tempting, but this question illustrates the reason why NOT to use them - what if you move your code and CANNOT enable them (for whatever reason)? The most portable code does not use short tags. If you need to turn them on to make old code work, then do what you have to do. If you're setting up a server to start a new project, leave 'em off!

Docs: http://www.php.net/manual/en/ini.core.php#ini.short-open-tag

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜