php print 函数

来源:互联网 发布:五星广电软件 编辑:程序博客网 时间:2024/06/10 21:34

还有一个重要的函数就是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!



0 0
原创粉丝点击