PHP echo 与 PHP 短回显标签 [英] PHP echo vs PHP short echo tags
问题描述
它们的安全性是否相同?我被告知使用
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
指令)与 PHP5.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 短回显标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!