2

Is there a php.ini setting to turn <?=$phpval?>-style output on, or has someone on this project been smoking too much ASP?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
wedstrom
  • 555
  • 1
  • 3
  • 14

3 Answers3

2

There is, but it is deprecated. You are looking for short_open_tag which enables <? (DANGER because of xml opening tags that are the same) and <?= (no danger)

As of php 5.4, <?= will be enabled even if short_open_tag is set to Off. See the documentation.

greg0ire
  • 22,714
  • 16
  • 72
  • 101
2

Yes,

<?php $var = 'Hello, World!"; ?>
<?= $var ?>

Is the same as;

<?php $var = 'Hello, World!"; ?>
<?php echo $var; ?>
Francisco Presencia
  • 8,732
  • 6
  • 46
  • 90
Skittles
  • 2,866
  • 9
  • 31
  • 37
1

Yes, Its a valid statement, and as @greg0ire mentioned you can turn it on by editing the short_open_tag in php.ini however using <?php has been known as a better practice specially if you are writing your application for sale to the public, because <?php would work with most shared hosting configurations however <? is sometimes not allowed/not activated, so its easier for users to use your script if you use <?php.

Ahoura Ghotbi
  • 2,866
  • 12
  • 36
  • 65