<?= ?> special tags in php

别说谁变了你拦得住时间么 提交于 2020-01-02 02:32:13

问题


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

<?= ?>

I couldn't find it on google.


回答1:


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.




回答2:


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




回答3:


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)




回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/2662476/special-tags-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!