Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP shorthand isn't working on new server? [duplicate]

Possible Duplicate:
<? ?> tags not working in php 5.3.1

I usually use shorthand syntax

 <?="hello";?>

instead of

 <?php echo "hello";?>

I created a development server and installed same version of php but shorthand method doesn't work, why? how can I fix it?

I would ask this on the server site, but this is related to a php setting or something I believe.

I'm running linux fedora 14

like image 904
Darius Avatar asked Apr 08 '11 23:04

Darius


3 Answers

You need to enable the short_open_tag option in the configuration file php.ini (probably in /etc/). As you have discovered, short tags are disabled by default.

Edit: and yes, as @Sebastian P points out, this has been asked before.

like image 175
andyb Avatar answered Oct 04 '22 20:10

andyb


Find your php.ini file in the apache directory and change short_open_tag = On

like image 29
satnhak Avatar answered Oct 04 '22 21:10

satnhak


You probably need to enable short tags, which is an ini setting as you supposed.

You should note that short tags are regarded by some as a bad idea (myself included). I know they are handy and thus tempting, but this question illustrates the reason why NOT to use them - what if you move your code and CANNOT enable them (for whatever reason)? The most portable code does not use short tags. If you need to turn them on to make old code work, then do what you have to do. If you're setting up a server to start a new project, leave 'em off!

Docs: http://www.php.net/manual/en/ini.core.php#ini.short-open-tag

like image 22
Chris Baker Avatar answered Oct 04 '22 22:10

Chris Baker