views:

121

answers:

4

can anybody please explain what are these special tags in php?

<?= ?>

I couldn't find it on google.

+1  A: 

They output what's inside them directly.

<?= "something" ?>

is a shortcut for:

<?php echo "something"; ?>

These (together with <? ?>) are called short tags. See here (short_open_tag)

Bozho
+4  A: 

It's part of the short_open_tag. Basically <?=$foo?> is equivalent to <?php echo $foo; ?>

WoLpH
Short_open_tag is primary <? ?>. "Short_open_tag also affects the shorthand <?=, which is identical to <? echo. Use of this shortcut requires short_open_tag to be on" - citation from php.net. So it is not basically short_open_tag.
retro
Indeed retro, I modified my answer to be more specific :)
WoLpH
A: 

<?= $foobar ?> is a shortcut for <?php echo $foobar; ?>.

I wouldn't recommend using these short tags because in some webserver environments they are disabled via PHPs configuration.

Techpriester
Any decent PHP application requires a lot of configuration options, from mod_rewrite to memory_limit and post_max_size. Go tell everyone these are not recommended for use
Col. Shrapnel
+4  A: 

See the short_open_tags setting. <?= is identical to <? echo and use of it requires short_open_tag to be on. A term to search for would be "short tags".

As an example: <?='hello'?> is identical to <? echo 'hello' ?> which is a short form of <?php echo 'hello' ?>.

See also Are PHP short tags acceptable to use? here on SO.

salathe
Thanks salathe for the detailed explanation!
heapzero
@heapzero: http://stackoverflow.com/questions/2413661/php6-is-short-open-tag-removed-or-deprecated-or-neither/2413675#2413675
Alix Axel
@Alix AxelThanks for the link!
heapzero