PHP回声vs PHP短标签 [英] PHP echo vs PHP short tags
问题描述
<?= $ function_here?>
不太安全,并且会减慢页面加载时间。
我严格偏向于使用echo。
有什么优点/缺点?
<?=
被称为短开标签,并不总是启用(请参阅 short_open_tag $ c $使用PHP 5.3或更低版本(但自PHP 5.4.0起,
<?=
始终可用)。
实际上,在PHP 5.3.0提供的php.ini-production文件中,默认情况下它们是禁用的:
$ grep'short_open'php.ini-production
; short_open_tag
short_open_tag =关闭
因此,在您要分发的应用程序中使用它们可能不会是一个好主意:如果您的应用程序未启用,您的应用程序将无法工作。
<?php
,on另一方面,不能被禁用 - 所以,使用这一个是最安全的,即使它写的时间更长。
除了事实上,短打开标签不一定启用,我不认为有很大的区别。
Are they equal in safeness? I was informed that using
<?=$function_here?>
was less safe, and that it slows down page load times. I am strictly biased to using echo.
What are the advantages/disadvantages?
<?
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).
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
, 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回声vs PHP短标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!