4

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

<? statements ?> 

and the browser don't interprets the code. If I use :

<?php statements ?>

everything works ok.

Any idea how to fix it. Thank you.

Bogdan S
  • 229
  • 7
  • 15

3 Answers3

7

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+.

Herbert
  • 5,698
  • 2
  • 26
  • 34
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.

Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236
  • 1
    You should do the modification manually in the php.ini in the `wamp\bin\php\php\php.ini` folder – Benjamin Crouzier Sep 05 '11 at 11:04
  • -1: although not yet deprecated there's enough debate over short_open_tags to suggest that using the full php tags is a better solution. See also http://stackoverflow.com/questions/2413661/php6-is-short-open-tag-removed-or-deprecated-or-neither – symcbean Sep 05 '11 at 11:17
1

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

Community
  • 1
  • 1
kieran
  • 2,304
  • 4
  • 28
  • 44
  • Agreed, but this doesn't answer the question. – Herbert Sep 05 '11 at 12:24
  • I didn't answer the question for a reason, that there is a good chance that further down the line this will be a bigger problem. I said you can change it in the php.ini file - but I wanted to raise the bigger issue that and not just give instructions on how to do it. – kieran Sep 05 '11 at 15:18
  • Once again, I agree with you, _as most competent developers probably will_. However, isn't it better to make this commentary within the context of an answer. "you can change it in the php.ini file" is hardly an answer. – Herbert Sep 05 '11 at 17:14