PHP基础 专题
您的位置:php > PHP基础 专题 > PHP print语句
PHP print语句
作者:--    发布时间:2019-11-20

类似于php echo语句,php print是一个语言结构(因为有返回值,可以认为它是函数),所以也不需要使用括号和参数列表。 与echo不同,它总是返回1

php print的语法如下:

int print(string $arg)

php print语句可以用来打印字符串,多行字符串,转义字符,变量,数组等。

php print:打印字符串

file: print1.php

<?php  
    print "hello by php print ";  
    print ("hello by php print()");  
?>

执行上面代码得到以下结果 -

hello by php print hello by php print()

php print:打印多行字符串

file: print2.php

<?php  
    print "hello by php print  
this is multi line  
text printed by   
php print statement  
";  
?>

执行上面代码得到以下结果 -

hello by php print this is multi line text printed by php print statement

php print:打印转义字符

file: print3.php

<?php  
    print "hello escape \"sequence\" characters by php print";  
?>

执行上面代码得到以下结果 -

hello escape "sequence" characters by php print

php print:打印变量值

file: print4.php

<?php  
    $msg="hello print() in php";  
    print "message is: $msg";   
?>

执行上面代码得到以下结果 -

message is: hello print() in php

网站声明:
本站部分内容来自网络,如您发现本站内容
侵害到您的利益,请联系本站管理员处理。
联系站长
373515719@qq.com
关于本站:
编程参考手册