English 中文(简体)
除了 la以外,还有很好的理由不使用<?=重复购买力平价变量? [复制]
原标题:Apart from it being lazy is there a good reason not use <?= to echo PHP variables? [duplicate]
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
What is the difference between the PHP open tags “<?=” and “<?php”/“<?”?

不是类型:

<?php echo $foo; ?>

I have seen it written

<?= $foo; ?>

但我常常想知道,这样做的风险/做法是什么? 公正。 感谢!

最佳回答

如果您将守则移至short_ open_tag的环境。 凭空,你可以找到许多内部变量名称(安全问题),并拥有大量受损产出。

另一边是,允许使用<代码><的相同术语? 同样,让你打开只有<代码><的PHP标签;,从而使其残疾不仅会暴露你试图展示的具体变量,而且会在短标内显示任何PHP代码。

问题回答

第二种选择提高了可读性。 第一项确保了其他系统的可运输性。

除此以外,没有任何差别......

它不可运输。 有一个预设结构,可以将其撤销,这样,如果你把手稿移至残疾地点,就会打破。

此外,我认为,这不够明确。 <代码><?= func() ?> and <? func();?>易于误解,但很重要。

You can only use <? and <?= if short tags are enabled when you are running PHP. The actual reason not to use it is because it s incompatible with an xml declaration. If you are trying to output xml with a php extension and you have short tags enabled, you have to do something like <<??>? .. I suppose you can just echo a string.

我不理解所有这种便携式话。

There is ALWAYS a portability issue.
There can be no apache - so, don t use mod_rewrite.
There can be no PDO - so, don t use prepared statements.
There can be no mysql - so, don t use complex queries.
There can be no PHP - so, plain HTML is most compatible format, never use anything else because of portability issues!





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签