<?= ?> special tags in php

2019-04-26 20:31发布

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

<?= ?>

I couldn't find it on google.

5条回答
女痞
2楼-- · 2019-04-26 20:59

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 ?>

查看更多
乱世女痞
3楼-- · 2019-04-26 21:00

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

查看更多
走好不送
4楼-- · 2019-04-26 21:02

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.

查看更多
Root(大扎)
5楼-- · 2019-04-26 21:08

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)

查看更多
6楼-- · 2019-04-26 21:16

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

查看更多
登录 后发表回答