【函数功能】
该函数输出一个或多个字符串。
【函数语法】
void echo ( string $arg1 [, string $... ] )
【参数说明】
$strings:必需,一个或多个要输出的字符串。
【演示程序】
<?php
/**
* echo ( string $arg1 [, string $... ] )
* **/
$a = 'hello ';
$b = 'i am ';
$c = 'PHP!';
echo $a,$b,$c;
echo '<br>'."hello i am $c".'<br>';
$str = array('key'=>'PHP!');
echo "hello i am $str[key]";
echo '<br>'."hello i am {$str['key']}";
?>
【输出结果】
hello i am PHP!
hello i am PHP!
hello i am PHP!
hello i am PHP!
【特别注意】
1.echo() 函数实际不是一个函数,所以您不必对它使用括号。然而,如果您希望向 echo() 传递一个以上的参数,使用括号将会生成解析错误。
2.echo() 函数比 print() 速度稍快。
3.echo() 函数也有简写语法。在 PHP 5.4.0 之前,该语法只适用于 short_open_tag 配置设置启用的情况。
4.PHP 版本:4+。
【原版定义】
Outputs all parameters. No additional newline is appended.
echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses.
echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.
转载请注明出处:php1234.cn ,原文地址:http://www.php1234.cn/a/functions/2016/1104/116.html