PHP5 中echo 和 print 语句
来源:才华咖 本文已影响1.2W人
来源:才华咖 本文已影响1.2W人
引导语:echo 和 print 是php5中的两条输出语句,以下是小编整理的PHP5 中echo 和 print 语句,欢迎参考阅读!
PHP echo 和 print 语句
echo 和 print 之间的差异:
echo - 能够输出一个以上的字符串
print - 只能输出一个字符串,并始终返回 1
提示:echo 比 print 稍快,因为它不返回任何值。
PHP echo 语句
echo 是一个语言结构,有无括号均可使用:echo 或 echo()。
显示字符串
下面的例子展示如何用 echo 命令来显示不同的字符串(同时请注意字符串中能包含 HTML 标记):
<?php
echo "<h2>PHP is fun!</h2>";
echo "Hello world!<br>";
echo "I'm about to learn PHP!<br>";
echo "This", " string", " was", " made", " with multiple parameters.";
?>
显示变量
下面的例子展示如何用 echo 命令来显示字符串和变量:
<?php
$txt1="Learn PHP";
$txt2="";
$cars=array("Volvo","BMW","SAAB");
echo $txt1;
echo "<br>";
echo "Study PHP at $txt2";
echo "My car is a {$cars[0]}";
?>
PHP print 语句
print 也是语言结构,有无括号均可使用:print 或 print()。
显示字符串
下面的.例子展示如何用 print 命令来显示不同的字符串(同时请注意字符串中能包含 HTML 标记):
<?php
print "<h2>PHP is fun!</h2>";
print "Hello world!<br>";
print "I'm about to learn PHP!";
?>
显示变量
下面的例子展示如何用 print 命令来显示字符串和变量:
<?php
$txt1="Learn PHP";
$txt2="";
$cars=array("Volvo","BMW","SAAB");
print $txt1;
print "<br>";
print "Study PHP at $txt2";
print "My car is a {$cars[0]}";
?>
A Bitter Experience in My Childhood初中英语作文
英语四级听力训练: this is the Technology Report
PHP中php://input和$-POST的区别
How to protect the environment初中英语作文
The Power of Cooperation英语作文
How to keep a good relationship with parents英语作文
WIndows 8可以支持Photoshop CS6和Lightroom 4
PHP中error-reporting函数用法
How To Control The Population英语作文
php中php://input和$-POST有什么不同
高中英语作文:My approach to difficulties in learning
英语四级作文The Importance of Physical Exercise
新概念英语青少版2a课文Unit 04:The top three persent
双语阅读:The Props to Help Man Endure
ThinkPHP中redirect用法实例分析
Why Public Speaking Is So Important 公共演说的重要性大学英语
Compare with the domestic hen and the duck英语作文
ThinkPHP中create()方法自动验证表单信息
php中file-get-contents与curl性能比较分析
浅谈php中curl和fsockopen的应用
Efforts Urged to Improve Womens Reproductive Health英语阅读
Why Respect Is Important英语作文
My Happy Times During Winter Vacation初中英语作文
php安装xdebug/pear/phpunit图文详解
php中file-get-contents与curl性能比较
2015年大学英语四级写作范文:Shopping through Media
商务英语写作prevent、prohibit和ban的使用方法及区别
Health in developing countries大学六级英语写作范文
一唱一和成语谜语及造句
初中英语写作范文:My Happy Times During Winter Vacation
理解PHP5中static和const关键字的差别
英语演讲稿《 I Am Tripping My Elephant Here》
Design and production of print ads Resume Writing
php中file-get-contents与curl性能分析
Thinkpad笔记本开机显示Tointerrruptnormalstartup解决方法
The composition of the tree英语作文
解决PHP中的Cannot modify header information 问题
php的file-put-contents()功能函数
php中file-get-contents与curl性能比较分析的内容
关于感恩的诗句和俗语多句