输出语句
- PHP输出语句:echo、 print
- echo 和 print 后面可以加也可以不加小括号 (
()
) - 不同:
- echo 没有返回值;print 返回
1
- echo 接受多个参数;print 只接受一个参数
- echo 比 print 执行稍快
示例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<title>Hello World!</title>
</head>
<body>
<div class="jumbotron">
<?php
echo("<h2>Learning PHP</h2>");
print("<blockquote>");
$newline = "<br>";
echo "PHP is a popular general-purpose scripting language ",
"that is especially suited to web development.", "$newline";
print "Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.";
print "</blockquote>";
?>
</div>
</body>
</html>
查看运行结果