Heim > Backend-Entwicklung > PHP-Tutorial > php 打印、显示、输出函数 收集_PHP教程

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

WBOY
Freigeben: 2016-07-13 17:37:47
Original
870 Leute haben es durchsucht

<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...
Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage