echo
- 用echo输出可以有括号也可以没有括号
- 不会返回任何值
- 可以传递多个参数,用逗号分割
- echo语句比print快
- 输出也是可以有括号和没括号
- 输出成功后,返回整行数字1
- 不能传递多个参数
- print比echo慢
代码演示
echo中多参数的逗号连接
<?php
$name = "xiaoming";
$age = "18";
$sex = "男"
echo "具体情况为".$name,$age,$sex;
//输出-->具体情况为xiaomi18男
如果使用print,直接报错
<?php
$name = "xiaoming";
$age = "18";
$sex = "男"
print "具体情况为".$name,$age,$sex;
//输出-->( ! ) Parse error: syntax error, unexpected 'print' (T_PRINT) in D:\APP\www\php\file\test.php on line 5
返回值情况,echo无返回值,print为1
<?php
$name = "xiaoming";
$age = "18";
$sex = "男"
$temp = echo "具体情况为".$name,$age,$sex;
echo $temp;
//输出-->Parse error: syntax error, unexpected '$temp' (T_VARIABLE) in D:\APP\www\php\file\test.php on line 5
<?php
$name = "xiaoming";
$age = "18";
$sex = "男";
$temp = print "具体情况为".$name;
echo "<br>";
echo $temp;
//输出-->1