php print是函数吗,PHP print() 函数

(PHP 4, PHP 5, PHP 7)

print — 输出字符串

说明

print ( string $arg ) : int

输出 arg。

print 实际上不是函数(而是语言结构),所以可以不用圆括号包围参数列表。

和 echo 最主要的区别: print 仅支持一个参数,并总是返回 1。

参数

arg

输入数据。

返回值

总是返回 1。

范例

Example #1 print 范例

print("Hello World");

print "print() also works without parentheses.";

print "This spans

multiple lines. The newlines will be

output as well";

print "This spans\nmultiple lines. The newlines will be\noutput as well.";

print "escaping characters is done \"Like this\".";

// 可以在打印语句中使用变量

$foo = "foobar";

$bar = "barbaz";

print "foo is $foo"; // foo is foobar

// 也可以使用数组

$bar = array("value" => "foo");

print "this is {$bar['value']} !"; // this is foo !

// 使用单引号将打印变量名,而不是变量的值

print 'foo is $foo'; // foo is $foo

// 如果没有使用任何其他字符,可以仅打印变量

print $foo; // foobar

print <<

This uses the "here document" syntax to output

multiple lines with $variable interpolation. Note

that the here document terminator must appear on a

line with just a semicolon no extra whitespace!

END;

print 'runoops.com'; //runoops.com

?>

注意: 因为是一个语言构造器而不是一个函数,不能被 可变函数 调用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值