开发者

PHP - WAMP server

I have a problem with WAMP server (2.1); I have some php files that contain php statements between

<? statements ?> 

and th开发者_如何学运维e browser don't interprets the code. If I use :

<?php statements ?>

everything works ok.

Any idea how to fix it. Thank you.


Whether you should or should not use short tags is debatable. I personally do not and I don’t recommend it. That being said — with WAMPServer 2 you can:

  1. Click on the wampserver tray icon.
  2. Go to PHP. Then PHP Settings
  3. Click short open tag. (When it's on it will have a checkmark next to it.)

Using the tray icon (lower right — next to the clock) is the easiest, least error prone way to make any changes in WAMPServer 2+.


As kieran said:

This is a good thread on why you shouldn't use short tags: Are PHP short tags acceptable to use?

If you decided to used them, add in your php.ini:

short_open_tag=On

Documentation for php.ini directives


Be carefull, in a wamp installation, php.ini can be found at multiple locations:

wamp\bin\apache\Apache<version>\bin\php.ini
wamp\bin\php\php<version>\php.ini

Accessing the php.ini from the wamp menu (left click on wamp tray icon / php / php.ini) opens the php.ini of the current apache version.


This is a good thread on why you shouldn't use short tags: Are PHP short tags acceptable to use?

Don't use <? statements ?> - short tags are evil!

You can change it in the php.ini file but it even says in that file not to use them...

This directive determines whether or not PHP will recognize code between tags as PHP source which should be processed as such. It's been recommended for several years that you not use the short tag "short cut" and instead to use the full tag combination. With the wide spread use of XML and use of these tags by other languages, the server can become easily confused and end up parsing the wrong code in the wrong context. But because this short cut has been a feature for such a long time, it's currently still ; supported for backwards compatibility, but we recommend you don't use them. Default Value: On ; Development Value: Off ; Production Value: Off ; http://www.php.net/manual/en/ini.core.php#ini.short-open-tag

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜