首页 > php代码 > php 5.2.x 不被注意的细节: 输出篇

php 5.2.x 不被注意的细节: 输出篇

1、在以前的版本里面可能会说 print 需要 () ,但是  php5.2.5中已经不需要了。
       echo 可以打印多个变量,print 不行

$a = "hello";
$b = "world";
echo $a,$b,"<br>";
echo $a.$b."<br>";
print $a.$b;

输出:

helloworld
helloworld
helloworld

但这样就会出现编译错误:

print $a,$b;

注意:$a $b 中间的是逗号

 

2、单引号跟双引号的区别:

$a = "hello";
$b = "world";
echo "$a $b";

输出:hello world

echo '$a $b';

输出:$a $b

还有一点要提的是像下面这样写是可以正常输出的

$arr = array("a" => 1);
echo $arr['a'];


文章地址:http://www.phprm.com/code/edf80f16aba09f46fce1022e3b8e780e.html

转载随意^^请带上本文地址!

标签:none

发表留言