php print 函数
2016-05-04 09:04
323 查看
还有一个重要的函数就是exit 函数,该函数类似echo,只是使用该函数输
出内容之后,会终止后面代码的执行,在很多时候,该函数非常有用。exit 函
数还有一个别名就是die 函数。
2.print 函数
另外一个常用的输出函数名为print,其声明格式如下所示:
int print ( string arg )
该函数总是返回1。严格来说print 也不是一个函数,而是一个语法结构,因此输出的时
候,参数不需要括号。
实例2-57 print 语句的应用
本实例演示print 语句的应用,其用法同echo 类似
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> print.php </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
//直接输出字符串
print("Hello World");
print "<br>";
//可以分成多行写字符串
print "i
want to
fly high";
print "<br>";
//输出引号
print "这一句输出引号 \"我在引号中\".";
// 字符串中包含变量
$foo = "foobar";
$bar = "barbaz";
print "<br>";
print "foo is $foo"; // foo is foobar
print "<br>";
$variable="test_variable";
//输出一段文字
print <<<END
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;
?>
</body>
</html>
Hello World
i want to fly high
这一句输出引号 "我在引号中".
foo is foobar
This uses the "here document" syntax to outputmultiple lines with test_variable interpolation. Note that the here document terminator must appear on a line with just a semicolon no extra whitespace!
出内容之后,会终止后面代码的执行,在很多时候,该函数非常有用。exit 函
数还有一个别名就是die 函数。
2.print 函数
另外一个常用的输出函数名为print,其声明格式如下所示:
int print ( string arg )
该函数总是返回1。严格来说print 也不是一个函数,而是一个语法结构,因此输出的时
候,参数不需要括号。
实例2-57 print 语句的应用
本实例演示print 语句的应用,其用法同echo 类似
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> print.php </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
//直接输出字符串
print("Hello World");
print "<br>";
//可以分成多行写字符串
print "i
want to
fly high";
print "<br>";
//输出引号
print "这一句输出引号 \"我在引号中\".";
// 字符串中包含变量
$foo = "foobar";
$bar = "barbaz";
print "<br>";
print "foo is $foo"; // foo is foobar
print "<br>";
$variable="test_variable";
//输出一段文字
print <<<END
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;
?>
</body>
</html>
Hello World
i want to fly high
这一句输出引号 "我在引号中".
foo is foobar
This uses the "here document" syntax to outputmultiple lines with test_variable interpolation. Note that the here document terminator must appear on a line with just a semicolon no extra whitespace!
相关文章推荐
- PHP实现获取并生成数据库字典的方法
- echo.php
- YII 安装(1.1.17版本)
- php 函 数
- 服务容器——laravel真正的核心,面向对象思想阐述
- BeanFactoryPostProcessor和BeanPostProcessor的区别
- PHP从数据库导出数据到excel,无插件(解决中文以及法语乱码问题)
- php的tips(数据库mysql中文写入问题)
- php的tips(json发送中文是出现null的问题)
- PHP之验证码的实现
- php实习的tips(常用的head头)
- php的tips(生成随机函数rand与srand)
- PHP之时间处理
- php的tips(explode函数)
- php实习的tips(in_array函数)
- PHP——时间格式转换
- PHP实现获取并生成数据库字典的方法
- php使用Header函数,PHP_AUTH_PW和PHP_AUTH_USER做用户验证
- PHP实现的限制IP投票程序IP来源分析
- PHP Wrapper在SAE上的应用方法