您现在的位置是:首页 > PHP函数

李清波 2021-06-17 PHP函数 1574 复制当前网址

print

PHP print() 函数

定义和用法

print() 函数输出一个或多个字符串。


语法

print(strings)


参数描述
strings必需。发送到输出的一个或多个字符串。


提示和注释

注释:print() 函数实际上不是函数,所以您不必对它使用括号。

注释:print() 函数稍慢于 echo()


例子

例子 1

<?php
$str = "Whos John Adams?";
print $str;
print "<br />";
print $str."<br />I dont know!";
?>

输出:

Whos John Adams?
Whos John Adams?
I dont know!


例子 2

<?php
print "This text
spans multiple
lines.";
?>

输出:

This text spans multiple lines.


例子 3

<?php
$color = "red";
print "Roses are $color";
print "<br />";
print Roses are $color;
?>

输出:

Roses are red
Roses are $color


文章来源:http://liqingbo.com/blog-834.html

上一篇:printf

下一篇:parse_str

评论