0

Possible Duplicate:
What does this symbol mean in PHP <?=
Reference - What does this symbol mean in PHP?

In some coding I've found, I've seen the author use <?= and ?> in his code. I'm wondering if this is some fancy PHP or another language. I'm eager to know the answer as I would love to learn off of this code. I believe it could be the Fuel PHP framework but I am not sure as there is no documentation for it. Thanks.

An example of it's use:

<?=SITEROOT?>
Community
  • 1
  • 1
Josh Ferrara
  • 727
  • 2
  • 8
  • 25

2 Answers2

5

They are called short tags, but you should avoid using it as much as you can, because the short tags can be set to Off and then your script wont work, so use <?php tags, http://php.net/manual/en/ini.core.php

Sudhir Bastakoti
  • 94,682
  • 14
  • 145
  • 149
  • Thank you for providing a link to the ini config. :) – Josh Ferrara Nov 27 '11 at 06:15
  • 5
    Psh. If you're writing code for yourself, it's entirely a personal preference thing. Only people writing libraries and such for public consumption should "avoid using it as much as you can"; for everyone else, they can decide whether they like it or not. Personally, i prefer `=` over ` – cHao Nov 27 '11 at 06:15
  • 2
    FYI, short tags are a replacement for ` – nickb Nov 27 '11 at 06:16
  • 2
    I heard = works now even if short tags is off. Is that true? – Ben Nov 27 '11 at 06:19
  • 2
    @Ben I can confirm that after I read the docs it will work on PHP 5.4.0 and above even if it is off. – Josh Ferrara Nov 27 '11 at 06:37
2

It's just an alternate way to write the <?php ?> tags, think of it as a synonym of <?php echo SITEROOT; ?>.

I believe it is a configuration item, some servers have it turned on, others don't; so it isn't 100% portable, other then that though, it is standard php functionality

Ben
  • 8,230
  • 6
  • 45
  • 61