Maison > php教程 > php手册 > php 打印、显示、输出函数 收集

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

WBOY
Libérer: 2016-06-13 10:36:16
original
1104 Les gens l'ont consulté

<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() 函数

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal