Morteza Ziyaeimehr
Morteza Ziyaeimehr

Reputation: 2117

Shorthand <? issue

I want to use the CakePHP shorthand <? in my project code instead of <?php, but my WAMP server (v2.1d-x64 on localhost) doesn't recognize it.

How can I activate it?

Upvotes: 1

Views: 483

Answers (5)

giorgio
giorgio

Reputation: 10202

You can activate it in your php.ini file. But good practice is to use the full string (<?php ... ?>). Not every PHP configuration allows the shorthand, and you do not have access to every server's php.ini (that is, if you host in a shared environment).

Upvotes: 2

knittl
knittl

Reputation: 265241

Set the configuration parameter short_open_tag to On in your php.ini file and restart your Apache server.

Upvotes: 1

Jon Gjengset
Jon Gjengset

Reputation: 4236

In you php.ini, add the following line:

short_open_tag On

Note that in your question, that's not what you've done.. There should be no "Default Value: On", just short_open_tag On on a line by itself.

Upvotes: 3

JK.
JK.

Reputation: 5136

In your php.ini, turn short_open_tag to on.

This is not recommended for portability reasons. My advice is to stick with the longer version.

Upvotes: 7

Dan Grossman
Dan Grossman

Reputation: 52372

This is PHP syntax, not part of your CakePHP framework. You need to edit your PHP configuration file (php.ini), change short_open_tag to 1, and restart Apache.

http://php.net/manual/en/ini.core.php

Upvotes: 2

Related Questions