> 백엔드 개발 > 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으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿