当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > print() 函数

PHP
php 无限分类的实现
常用PHP代码
windows下安装配置php视频教程
MySQL数据库结构和数据的导出和导入
PHP实现 IP Whois 查询
PHP5 this,self和parent关键字详解
PHP 安全技巧连载 #1[译]
PHP 安全技巧连载 #2[译]
PHP 安全技巧连载 #3[译]
PHP 安全技巧连载 #4[译]
PHP 安全技巧连载 #5[译]
PHP 安全技巧连载 #6[译]
PHP 安全技巧连载 #7[译]
PHP 安全技巧连载 #8[译]
PHP 安全技巧连载 #9[译]
PHP 安全技巧连载 #10[译]
PHP 安全技巧连载 #11[译]
PHP error_reporting的使用
PHP 安全技巧连载 #12
使用PHP做Linux/Unix守护进程

PHP 中的 print() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 534 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The print() function outputs one or more strings.
print()函数的作用是:输出字符串。

Syntax
语法

print(strings)

Parameter参数 Description描述
strings Required. One or more strings to be sent to the output
必要参数。指定一个或多个发送到结果的字符串


Tips and Notes
提示和注意点

Note: The print() function is not actually a function, so you are not required to use parentheses with it.
注意:print()函数并不是一个真正意义上的函数,所以你不一定需要再声明它的时候加上圆括号“()”

Tip: The print() function is slightly slower than echo().
提示:print()函数的运行速度比echo()函数稍慢一些。


Example 1
案例1

<?php
$str = "Who's Kai Jim?";
print $str;
print "<br />";
print $str."<br />I don't know!";
?> 

The output of the code above will be:
上述代码将输出下面的结果:

Who's Kai Jim?
Who's Kai Jim?
I don't know!


Example 2
案例2

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

The output of the code above will be:
上述代码将输出下面的结果:

This text spans multiple lines.


Example 3
案例3

Difference of single and double quotes. Single quotes will print the variable name, not the value:
比较单引号(')和双引号(")的不同点。使用单引号(')输出的是变量名,而不是变量值:

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

The output of the code above will be:
上述代码将输出下面的结果:

Roses are red
Roses are $color

评论 (0) All

登陆 | 还没注册?