Page 1 of 1

Trouble with the <?= syntax

Posted: Wed Dec 03, 2008 4:11 am
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?

Re: Trouble with the <?= syntax

Posted: Wed Dec 03, 2008 4:36 am
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

Re: Trouble with the <?= syntax

Posted: Sat Dec 06, 2008 1:22 pm
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.

Re: Trouble with the <?= syntax

Posted: Sat Dec 06, 2008 1:56 pm
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. :)