I'm using PHP frameworks like codeigniter and fuelphp, I read some of it's manual that i's recommending <?=
over <?php echo
. But I don't use both of them, instead I'm using <? echo
, but I'm still not sure if I'm doing it right. I don't feel comfortable using <?=
. Need advice from experienced PHP developers. Thanks in advance.

- 622
- 6
- 18
-
1Possible duplicate of [PHP = vs – Naresh Kumar May 20 '16 at 03:48
-
`I'm using echo` it would not work. Btw always use `` .feel comfortable. – Niklesh Raut May 20 '16 at 03:51
-
you can use `<=` but you also have to set the true of short syntax in php.ini file. then that will be equal to echo otherwise it will prompt error. – NomanJaved May 20 '16 at 04:25
-
1Possible duplicate of [Are PHP short tags acceptable to use?](http://stackoverflow.com/questions/200640/are-php-short-tags-acceptable-to-use) – Oleg Antonyan May 20 '16 at 04:30
3 Answers
PHP has deprecated the use of <?
as it has been adopted by other programming langs
It's recommended to use <?php
if you feel confortable.
Enjoy your coding...

- 31
- 5
First of all, <? ... ?>
is the short code of <?php ... ?>
... Here's what it says from the PHP Documentation itself:
http://php.net/manual/en/ini.core.php#ini.short-open-tag
short_open_tag boolean
Tells PHP whether the short form () of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use inline. Otherwise, you can print it with PHP, for example: '; ?>. Also, if disabled, you must use the long form of the PHP open tag ().
To have that working on your server, the short_open_tag
must be enabled in your php.ini
. There's no right or wrong way of writing it, but some people prefer the old long way <?php ... ?>
, such as me, because I find it easier to read.
Same thing for the <?=
, here's what the PHP Documentation say
echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.
For more information about echo:

- 14,621
- 3
- 34
- 58
-
1Note that on a lot of servers, short_open_tags are disabled, so if you don't maintain your own server, it is safer to not rely on this feature. – WanWizard Jun 14 '16 at 09:10
There is no right or wrong for this, it's an opinion based matter. I personally do like to use shorttags when I can because I find it easier to read. Others might find the
<?php
easier to read and will prefer this. It's a fully opinion based matter and I wouldnt worry about it. Use which you prefer.

- 1,251
- 2
- 15
- 37