<?=是什么意思? [英] What does <?= mean?
问题描述
此行的含义
<input type=text name="name" value="<?= $name ?>
如果我们要声明为PHP,则不应该编写<?php instead of <?=
if we are to declare as PHP shouldn't we write <?php instead of <?=
谢谢
推荐答案
<?=
are PHP short open tags, which can be enabled (or disabled) via the short_open_tag
directive in php.ini
(quoting) :
此指令也会影响 速记
<?=
,相同 到<? echo
.使用此快捷方式 要求short_open_tag
为on
.
This directive also affects the shorthand
<?=
, which is identical to<? echo
. Use of this shortcut requiresshort_open_tag
to beon
.
并且:
如果已禁用,还必须使用 PHP开放标记(
<?php ?>
)的长格式.
Also if disabled, you must use the long form of the PHP open tag (
<?php ?>
).
这意味着您的代码部分:
This means your portion of code :
<input type=text name="name" value="<?= $name ?>
等效于此:
<input type=text name="name" value="<?php echo $name; ?>
但是只有启用短打开标签.
而且,作为一个旁注:短打开标记并不总是启用的-实际上,在最新版本的PHP中,默认情况下它们是禁用的.
And, as a sidenote : short open tags are not always enabled -- in fact, they are disabled by default, with recent versions of PHP.
这意味着不依赖于这些选项可能是明智的选择,至少如果您希望将应用程序部署在非管理员的服务器上.
Which means it might be wise to not depend on those, at least if you want to deploy your application on servers on which you are not administrator.
这篇关于<?=是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!