7

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

<?= ?>

I couldn't find it on google.

miken32
  • 35,483
  • 13
  • 81
  • 108
heapzero
  • 1,293
  • 2
  • 12
  • 18

5 Answers5

7

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.

Community
  • 1
  • 1
salathe
  • 48,441
  • 11
  • 98
  • 127
4

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

Wolph
  • 69,888
  • 9
  • 125
  • 143
  • 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 Apr 18 '10 at 14:16
  • Indeed retro, I modified my answer to be more specific :) – Wolph Apr 19 '10 at 00:04
1

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
  • 554,002
  • 136
  • 1,025
  • 1,121
0

yes you can done it using .htaccess. In your .htaccess file, add this

php_value short_open_tag 1

Now you can check files with <?='hi';?> instead of <?php ?>

Brad Larson
  • 168,330
  • 45
  • 388
  • 563
php
  • 3,569
  • 1
  • 18
  • 13
0

<?= $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.

selfawaresoup
  • 14,267
  • 7
  • 32
  • 45
  • 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 – Your Common Sense Apr 18 '10 at 15:06