Trouble with the <?= syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Mark Oates
Forum Newbie
Posts: 4
Joined: Wed Dec 03, 2008 3:52 am

Trouble with the <?= syntax

Post by Mark Oates »

Hello everybody, this is my first post on this forum so everybody say hello! :)

I recently found the <?= syntax for quickly printing a variable and have been thrilled, eg:

Code: Select all

 
<title><?=$page_title?></title>
<meta name="description" content="<?=$page_description?>">
<meta name="keywords" content="<?=$page_keywords?>">
 
However, on my current job I'm working with a host where that syntax doesn't work. The host is Verio, I've never used them before. The php ver is 5.2.2 so my next guess is that I need to flip a switch in the .htaccess file or a setting elsewhere. I can't google for "<?=" and I don't know what it's called so I'm posting here for some help.

Can anybody tell me where to get info on this?
mmj
Forum Contributor
Posts: 118
Joined: Fri Oct 31, 2008 4:00 pm

Re: Trouble with the <?= syntax

Post by mmj »

I personally never use "short tags" and it isn't generally recommended in the PHP community, especially when writing code meant to be portable.

http://www.php.net/manual/en/ini.core.p ... t-open-tag

Try this in .htaccess:
php_flag short_open_tag on
User avatar
Mark Oates
Forum Newbie
Posts: 4
Joined: Wed Dec 03, 2008 3:52 am

Re: Trouble with the <?= syntax

Post by Mark Oates »

Thanks mmj, that did work.

I didn't realize it was a short tag, so I'll be sure to use it with discretion in the future.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Trouble with the <?= syntax

Post by califdon »

Welcome, Mark. Yes, it's generally agreed that use of short tags is not good practice, as mmj said. Portability and use with other scripting languages means you would limit the usefulness of your script. It's much easier to just type 3 more keystrokes each time. :)
Post Reply