6

What does this symbol mean in PHP <?=?

Example usage:

<h2>Manage Role: > (<?= $myACL->getRoleNameFromID($_GET['roleID']); ?>)</h2> 
Adrian Toman
  • 11,316
  • 5
  • 48
  • 62
ekalaivan
  • 443
  • 1
  • 6
  • 17

4 Answers4

13

To add to Mark's answer: The short_tags option must be enabled for the <?= syntax to be valid. This presents a major portability problem when moving to a server that has this option disabled.

See the PHP Manual for more info on short tags

Mike B
  • 31,886
  • 13
  • 87
  • 111
  • Couldn't the user simply call `ini_set('short_open_tag', 1)` to override? Or if short tags are disabled, is the `ini_set` function normally disabled as well? – Doug Neiner Dec 26 '09 at 17:52
  • 6
    @Doug: actually, by the time the user was allowed to call `ini_set`, the file was already parsed. So it's too late at that point. The best alternative is a directive in `.htaccess` or `httpd.conf` if you can. – gahooa Dec 26 '09 at 17:57
  • 4
    MikeB, the `short_open_tag` option no longer applies to `=` [as of PHP 5.4](http://docs.php.net/manual/en/migration54.new-features.php). – 0b10011 Jul 18 '12 at 01:20
11

It's functionally the same as <?php echo $myACL->getRoleNameFromID($_GET['roleID']); ?>

Mark Biek
  • 146,731
  • 54
  • 156
  • 201
6

It's the PHP Short Tag equivalent of printing.

From the PHP INI:

Using short tags is discouraged when developing code meant for redistribution ; since short tags may not be supported on the target server.

See "Are PHP Short Tags Acceptable to Use?" on StackOverflow.

Community
  • 1
  • 1
Sampson
  • 265,109
  • 74
  • 539
  • 565
1
The <?= ... > tag says to execute whatever is in ... and output the results.
Reverend Gonzo
  • 39,701
  • 6
  • 59
  • 77