PHP代码中的<?= $ varname?>语法是什么? [重复]
问题描述:
This question already has an answer here:
Previous I bumped into codes like this:
<?php
$var="hello";
?>
<?=$var?>
It simply prints out the content of $var, so... is the syntax equivalent to echo $var
?
I'll also appreciate an answer pointing to a related manual page. Since the syntax is not searchable.
</div>
此问题已经存在 这里有一个答案: p>
-
参考 - 这个符号在PHP中意味着什么?
18 answers
\ n span>
li>
ul>
div>
上一篇我碰到了这样的代码: p>
&lt;?php $ var =“hello”; ?&gt; &lt;?= $ var?&gt; 代码> pre>
它只是打印出$ var的内容,所以...是等同于
echo $ var code>的语法? 我也很感激 回答指向相关的手册页。 由于语法不可搜索。 p> div>
答
Yes, <?=$var?>
is the same as <?php echo $var; ?>
From PHP.net manual: echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.
You can read more here.