问题描述
它们的安全性是否相等?我被告知使用
Are they equal in safeness? I was informed that using
<?=$function_here?>
不太安全,并且减慢了页面加载时间.我严格偏向使用echo.
was less safe, and that it slows down page load times.I am strictly biased to using echo.
优点/缺点是什么?
推荐答案
<?
和<?=
被称为短打开标记,并且并不总是启用的(请参见 short_open_tag
指令),且PHP 5.3或更低版本(但自PHP 5.4.0起,<?=
始终可用).
<?
and <?=
are called short open tags, and are not always enabled (see the short_open_tag
directive) with PHP 5.3 or below (but since PHP 5.4.0, <?=
is always available).
实际上,在PHP 5.3.0随附的php.ini-production文件中,默认情况下将其禁用:
Actually, in the php.ini-production file provided with PHP 5.3.0, they are disabled by default:
$ grep 'short_open' php.ini-production
; short_open_tag
short_open_tag = Off
因此,在要分发的应用程序中使用它们可能不是一个好主意:如果未启用它们,则您的应用程序将无法工作.
So, using them in an application you want to distribute might not be a good idea: your application will not work if they are not enabled.
<?php
-因此,即使写入时间更长,使用它也是最安全的.
<?php
, on the other side, cannot be disabled -- so, it's safest to use this one, even if it is longer to write.
除了不一定要启用短开放标签之外,我认为没有太大区别.
Except the fact that short open tags are not necessarily enabled, I don't think there is much of a difference.
这篇关于PHP echo与PHP short echo标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!