echo和print的区别

时间:2023-03-10 01:40:54
echo和print的区别

1、echo可以同时输出多个字符串;

echo 'this',' string',' is'," hello world\n";

2、print有返回值,但是运行速度上echo比较快;

$str='Hello World';
$a=print "This is a string $str\n";
var_dump($a);

  输出结果:

This is a string Hello World
int(1)

  如果在echo的前面加一个$a=的还就会报语法错误