-1

I was upgrading a client's site the other day and noticed that the previous developer had used <?=$foo?> to echo out variable $foo in the code. I know from my days in VBScript that using <%=foo%> works to write out variables to the screen but I had never seen it in PHP nor can I find any documentation on it in Google (part of this is probably because I don't know what this shorthand is technically called).

Is this ok to use or is this deprecated? Does anyone have any further information on this method of echo'ing variables in PHP?

Thanks!

MillerMedia
  • 3,651
  • 17
  • 71
  • 150

1 Answers1

2

From the manual

short_open_tag
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 ().

Note: This directive also affected the shorthand <?= before PHP 5.4.0, which is identical to <? echo. Use of this shortcut required short_open_tag to be on. Since PHP 5.4.0, <?= is always available.

asp_tags
Enables the use of ASP-like <% %> tags in addition to the usual <?php ?> tags. This includes the variable-value printing shorthand of <%= $value %>.

John Conde
  • 217,595
  • 99
  • 455
  • 496