﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-点滴生活</title><link>http://www.cnitblog.com/ighsot/</link><description /><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 07:12:45 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 07:12:45 GMT</pubDate><ttl>60</ttl><item><title>PHP 中，echo() 和 print() 的异同</title><link>http://www.cnitblog.com/ighsot/archive/2009/02/23/54837.html</link><dc:creator>Tiger</dc:creator><author>Tiger</author><pubDate>Mon, 23 Feb 2009 08:26:00 GMT</pubDate><guid>http://www.cnitblog.com/ighsot/archive/2009/02/23/54837.html</guid><wfw:comment>http://www.cnitblog.com/ighsot/comments/54837.html</wfw:comment><comments>http://www.cnitblog.com/ighsot/archive/2009/02/23/54837.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/ighsot/comments/commentRss/54837.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/ighsot/services/trackbacks/54837.html</trackback:ping><description><![CDATA[刚接触 PHP ，其中有两个打印（输出函数），即 echo() 和 print()，咋看起来很像。于是乎，在网上查询了一下，以下是来自官方的 Q&amp;A:<br>
<h2>What is the difference between echo and print?</h2>
<p><br>
</p>
<pre>1. Speed.  There is a difference between the two, but speed-wise it should be irrelevant which one you use. <br /> 
echo is marginally faster since it doesn't set a return value if you really want to get down to the nitty gritty.
</p>
2. Expression.  print() behaves like a function in that you can do:
$ret = print "Hello World"; And $ret will be 1.  That means that print
can be used as part of a more complex expression where echo cannot.  An
example from the PHP Manual:
$b ? print "true" : print "false";
print is also part of the precedence table which it needs to be if it
is
to be used within a complex expression. It is just about at the bottom
of the precedence list though.  Only "," AND, OR and XOR are lower.
3. Parameter(s).  The grammar is: echo expression [, expression[,
expression] ... ] But echo ( expression, expression ) is not valid.
This would be valid: echo ("howdy"),("partner"); the same as: echo
"howdy","partner";   (Putting the brackets in that simple example
serves
no purpose since there is no operator precedence issue with a single
term like that.)
So, echo without parentheses can take multiple parameters, which get
concatenated:
echo  "and a ", 1, 2, 3;   // comma-separated without parentheses
echo ("and a 123");        // just one parameter with parentheses
print() can only take one parameter:
print ("and a 123");
print  "and a 123";
</pre><img src ="http://www.cnitblog.com/ighsot/aggbug/54837.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/ighsot/" target="_blank">Tiger</a> 2009-02-23 16:26 <a href="http://www.cnitblog.com/ighsot/archive/2009/02/23/54837.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux 命令行下执行 PHP 脚本</title><link>http://www.cnitblog.com/ighsot/archive/2009/02/23/54827.html</link><dc:creator>Tiger</dc:creator><author>Tiger</author><pubDate>Mon, 23 Feb 2009 02:44:00 GMT</pubDate><guid>http://www.cnitblog.com/ighsot/archive/2009/02/23/54827.html</guid><wfw:comment>http://www.cnitblog.com/ighsot/comments/54827.html</wfw:comment><comments>http://www.cnitblog.com/ighsot/archive/2009/02/23/54827.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/ighsot/comments/commentRss/54827.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/ighsot/services/trackbacks/54827.html</trackback:ping><description><![CDATA[在 linux 命令汗下执行 PHP 脚本：<br><br><span style="FONT-FAMILY: Lucida Console">php [options] [-f] &lt;file&gt; [--] [args...]<br><br>e.g:<br>&nbsp;&nbsp;&nbsp; php -f hello_world.php<br><br>more info please type "php --help" or "man php"</span> 
<img src ="http://www.cnitblog.com/ighsot/aggbug/54827.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/ighsot/" target="_blank">Tiger</a> 2009-02-23 10:44 <a href="http://www.cnitblog.com/ighsot/archive/2009/02/23/54827.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>