首页 > 后端开发 > php教程 > php 打印、显示、输出函数 收集_PHP教程

php 打印、显示、输出函数 收集_PHP教程

WBOY
发布: 2016-07-13 17:37:47
原创
871 人浏览过

<span style="color: rgb(0,0,0)"><font face="NSimsun"><span style="color: rgb(0,0,187)"><?php <br /> </span><span style="color: rgb(0,119,0)">echo </span><span style="color: rgb(221,0,0)">"Hello World"</span></font><span style="color: rgb(0,119,0)"><font face="NSimsun">;<br> <br> echo </font></span><span style="color: rgb(221,0,0)"><font face="NSimsun">"This spans<br> multiple lines. The newlines will be<br> output as well"</font></span><font face="NSimsun"><span style="color: rgb(0,119,0)">;<br> <br> echo </span><span style="color: rgb(221,0,0)">"This spans multiple lines. The newlines will be output as well."</span></font><font face="NSimsun"><span style="color: rgb(0,119,0)">;<br> <br> echo </span><span style="color: rgb(221,0,0)">"Escaping characters is done "Like this"."</span></font><span style="color: rgb(0,119,0)"><font face="NSimsun">;<br> <br> </font></span><font face="NSimsun"><span style="color: rgb(255,128,0)">// You can use variables inside of an echo statement<br> </span><span style="color: rgb(0,0,187)">$foo </span><span style="color: rgb(0,119,0)">= </span><span style="color: rgb(221,0,0)">"foobar"</span></font><font face="NSimsun"><span style="color: rgb(0,119,0)">;<br> </span><span style="color: rgb(0,0,187)">$bar </span><span style="color: rgb(0,119,0)">= </span><span style="color: rgb(221,0,0)">"barbaz"</span></font><font face="NSimsun"><span style="color: rgb(0,119,0)">;<br> <br> echo </span><span style="color: rgb(221,0,0)">"foo is </span><span style="color: rgb(0,0,187)">$foo</span><span style="color: rgb(221,0,0)">"</span><span style="color: rgb(0,119,0)">; </span></font><font face="NSimsun"><span style="color: rgb(255,128,0)">// foo is foobar<br> <br> // You can also use arrays<br> </span><span style="color: rgb(0,0,187)">$baz </span><span style="color: rgb(0,119,0)">= array(</span><span style="color: rgb(221,0,0)">"value" </span><span style="color: rgb(0,119,0)">=> </span><span style="color: rgb(221,0,0)">"foo"</span></font><font face="NSimsun"><span style="color: rgb(0,119,0)">);<br> <br> echo </span><span style="color: rgb(221,0,0)">"this is </span><span style="color: rgb(0,119,0)">{</span><span style="color: rgb(0,0,187)">$baz</span><span style="color: rgb(0,119,0)">[</span><span style="color: rgb(221,0,0)">value</span><span style="color: rgb(0,119,0)">]}</span><span style="color: rgb(221,0,0)"> !"</span><span style="color: rgb(0,119,0)">; </span></font><font face="NSimsun"><span style="color: rgb(255,128,0)">// this is foo !<br> <br> // Using single quotes will print the variable name, not the value<br> </span><span style="color: rgb(0,119,0)">echo </span><span style="color: rgb(221,0,0)">foo is $foo</span><span style="color: rgb(0,119,0)">; </span></font><font face="NSimsun"><span style="color: rgb(255,128,0)">// foo is $foo<br> <br> // If you are not using any other characters, you can just echo variables<br> </span><span style="color: rgb(0,119,0)">echo </span><span style="color: rgb(0,0,187)">$foo</span><span style="color: rgb(0,119,0)">;          </span></font><font face="NSimsun"><span style="color: rgb(255,128,0)">// foobar<br> </span><span style="color: rgb(0,119,0)">echo </span><span style="color: rgb(0,0,187)">$foo</span><span style="color: rgb(0,119,0)">,</span><span style="color: rgb(0,0,187)">$bar</span><span style="color: rgb(0,119,0)">;     </span></font><font face="NSimsun"><span style="color: rgb(255,128,0)">// foobarbarbaz<br> <br> // Some people prefer passing multiple parameters to echo over concatenation.<br> </span><span style="color: rgb(0,119,0)">echo </span><span style="color: rgb(221,0,0)">This </span><span style="color: rgb(0,119,0)">, </span><span style="color: rgb(221,0,0)">string </span><span style="color: rgb(0,119,0)">, </span><span style="color: rgb(221,0,0)">was </span><span style="color: rgb(0,119,0)">, </span><span style="color: rgb(221,0,0)">made </span><span style="color: rgb(0,119,0)">, </span><span style="color: rgb(221,0,0)">with multiple parameters.</span><span style="color: rgb(0,119,0)">, </span><span style="color: rgb(0,0,187)">chr</span><span style="color: rgb(0,119,0)">(</span><span style="color: rgb(0,0,187)">10</span></font><font face="NSimsun"><span style="color: rgb(0,119,0)">);<br> echo </span><span style="color: rgb(221,0,0)">This </span><span style="color: rgb(0,119,0)">. </span><span style="color: rgb(221,0,0)">string </span><span style="color: rgb(0,119,0)">. </span><span style="color: rgb(221,0,0)">was </span><span style="color: rgb(0,119,0)">. </span><span style="color: rgb(221,0,0)">made </span><span style="color: rgb(0,119,0)">. </span><span style="color: rgb(221,0,0)">with concatenation. </span><span style="color: rgb(0,119,0)">. </span><span style="color: rgb(221,0,0)">" "</span></font><span style="color: rgb(0,119,0)"><font face="NSimsun">;<br> <br> echo </font></span><font face="NSimsun"><span style="color: rgb(221,0,0)">This uses the "here document" syntax to output<br> multiple lines with </span><span style="color: rgb(0,0,187)">$variable</span></font><span style="color: rgb(221,0,0)"><font face="NSimsun"> interpolation. Note<br> that the here document terminator must appear on a<br> line with just a semicolon. no extra whitespace!<br> </font></span><span style="color: rgb(0,119,0)"><font face="NSimsun">END;<br> <br> </font></span><font face="NSimsun"><span style="color: rgb(255,128,0)">// Because echo does not behave like a function, the following code is invalid.<br> </span><span style="color: rgb(0,119,0)">(</span><span style="color: rgb(0,0,187)">$some_var</span><span style="color: rgb(0,119,0)">) ? echo </span><span style="color: rgb(221,0,0)">true </span><span style="color: rgb(0,119,0)">: echo </span><span style="color: rgb(221,0,0)">false</span></font><span style="color: rgb(0,119,0)"><font face="NSimsun">;<br> <br> </font></span><font face="NSimsun"><span style="color: rgb(255,128,0)">// However, the following examples will work:<br> </span><span style="color: rgb(0,119,0)">(</span><span style="color: rgb(0,0,187)">$some_var</span><span style="color: rgb(0,119,0)">) ? print </span><span style="color: rgb(221,0,0)">true </span><span style="color: rgb(0,119,0)">: print </span><span style="color: rgb(221,0,0)">false</span><span style="color: rgb(0,119,0)">; </span></font><font face="NSimsun"><span style="color: rgb(255,128,0)">// print is also a construct, but<br>                                              // it behaves like a function, so<br>                                              // it may be used in this context.<br> </span><span style="color: rgb(0,119,0)">echo </span><span style="color: rgb(0,0,187)">$some_var </span><span style="color: rgb(0,119,0)">? </span><span style="color: rgb(221,0,0)">true</span><span style="color: rgb(0,119,0)">: </span><span style="color: rgb(221,0,0)">false</span><span style="color: rgb(0,119,0)">; </span></font><font face="NSimsun"><span style="color: rgb(255,128,0)">// changing the statement around<br> </span><span style="color: rgb(0,0,187)">?></span> </font></span>


====================
PHP die() 函数

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/486540.htmlTechArticle?php echo Hello World ; echo This spans multiple lines. The newlines will be output as well ; echo This spansmultiple lines. The newlines will beoutput as well. ; echo Escaping cha...
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板