Page 1 of 1

How to add <?= in php.ini

PostPosted: 19. April 2010 16:59
by dimko
Hi,

Can someone tell me how can I add "<?=" in php.ini or some other file, so the server can read it as a starting of a php command, just like "<?php" is.

Thanks.

Re: How to add <?= in php.ini

PostPosted: 19. April 2010 18:29
by Altrea
<?= is not equal with <?php.

<?= is the short open tag for <?php echo
<? is the short open Tag for <?php

You can use short open tags by activate short_open_tag in the php.ini.

But its recommend to use the full open tags, not the short ones.

Re: How to add <?= in php.ini

PostPosted: 19. April 2010 19:10
by dimko
Thanks for the quick replay and the explanation. I find it out, in php.ini, you should just change "Off" in "short_open_tag = Off" to "On". Don't forget to restart Apache ;)

Re: How to add <?= in php.ini

PostPosted: 19. April 2010 21:44
by memilanuk
This may be a silly question... but is there a (good) reason why you'd need to do this?

Re: How to add <?= in php.ini

PostPosted: 20. April 2010 20:34
by WilliL
memilanuk wrote:This may be a silly question... but is there a (good) reason why you'd need to do this?

yes, in next versions of php it will give no switch "short open tag"

Re: How to add <?= in php.ini

PostPosted: 20. April 2010 21:14
by Nobbie
WilliL wrote:yes, in next versions of php it will give no switch "short open tag"


No, thats not true. It was supposed to be removed, but it hasn't been. Its not "deprecated" in PHP5.x

Re: How to add <?= in php.ini

PostPosted: 20. April 2010 21:16
by memilanuk
I guess thats what I'm asking... if using the short open tag is slated to be deprecated (sooner or later), why is the OP trying to specifically enable that feature, rather than working with the current (and future) accepted standard of using the full <?php tag?

Re: How to add <?= in php.ini

PostPosted: 20. April 2010 21:34
by Nobbie
memilanuk wrote: why is the OP trying to specifically enable that feature, rather than working with the current (and future) accepted standard of using the full <?php tag?


Because "<?=$variable?>" is one of the most important, most elegant and basic (and oldest) features of PHP for usage of dynamic variables in HTML templates. The full TAG syntax is very ugly and cloggy: "<?php echo $variable;>"

Re: How to add <?= in php.ini

PostPosted: 21. April 2010 00:26
by dimko
memilanuk wrote:This may be a silly question... but is there a (good) reason why you'd need to do this?

Because I have same script that is coded with that kind of tags, and I don't want to search and replace it :)

Re: How to add <?= in php.ini

PostPosted: 21. April 2010 13:18
by xandrani
memilanuk wrote:why is the OP trying to specifically enable that feature, rather than working with the current (and future) accepted standard of using the full <?php tag?


Backwards compatibility with everyone's PHP scripts surely? If someone has used <? on one system and then moves to XAMPP, then allowing short tags will make their code still work. It's a bit like web browsers... it's possible to design an ultra strict HTML engine however hardly any websites would actually display then! In theory perfection is wonderful... in practise it breaks everything ;)