Php <;之间有什么区别吗=$价值?>;以及<;?echo$value&燃气轮机;
环境:Windows/7+Apache/2.2.21+PHP/5.3.8Php <;之间有什么区别吗=$价值?>;以及<;?echo$value&燃气轮机;,php,Php,环境:Windows/7+Apache/2.2.21+PHP/5.3.8 test.php的文件内容: hello, <?=$test?> <?php $test = 'world'; require './test.php'; ?> <?php global $test; $test = 'world'; require './test.php'; ?> index2.php的文件内容: hello, <?=$test?> <?
test.php的文件内容
:
hello, <?=$test?>
<?php
$test = 'world';
require './test.php';
?>
<?php
global $test;
$test = 'world';
require './test.php';
?>
index2.php的文件内容
:
hello, <?=$test?>
<?php
$test = 'world';
require './test.php';
?>
<?php
global $test;
$test = 'world';
require './test.php';
?>
index2.php的输出为:
hello, world
当test.php
的内容为:
hello,
hello, <? echo $test; ?>
所以,我的问题是:
和
之间有什么区别吗?在这方面,
和
之间没有输出区别
尽管我认为这种包含活动PHP文件的技术在这种特定情况下并不是最佳实践
谢。不,没有区别。我唯一想到的一点是,
有一点不同,那可能非常非常烦人。如果在php.ini中,将short\u open\u tag
设置为false,您将收到许多错误。否则,就完全一样了
在任何情况下,最后一个在之前的code>是可选的。$test=“hi”;要求'test.php'/$test在test.php的范围内代码>。不是我的反对票,这就是test.php
中的全部内容吗?没有功能或其他范围限制结构?@Scott这就是标题says@Charlie标题经过编辑,一开始没有这么说。添加error\u reporting(E\u ALL)代码>在index1.php的顶部,或者它没有发生。抱歉,这是我的错,没有阅读源代码。尽管我不是投票人。但是你的两句话是矛盾的。首先,你说没有区别,第二,你说有区别。对不起,我就是那个。你的答案与这个问题无关:-原来。。。(不是关于短代码,而是变量范围)@RokKralj:实际上没有区别。如果启用了allow_short_标记