位置: 编程技术 - 正文
推荐整理分享PHP字符串函数echo()的用法(在php中,字符串有哪些表示形式),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:php中字符串函数,php字符串型数据的定义方式,php字符串定义,php字符串赋值,php字符串定义,php字符串定义,php 字符串函数,php 字符串函数,内容如对您有帮助,希望把文章链接给更多的朋友!
(PHP 4, PHP 5)
echo — 输出一个或多个字符串
说明 void echo ( string $arg1 [, string $... ] )输出所有参数。
echo 不是一个函数(它是一个语言结构), 因此你不一定要使用小括号来指明参数,单引号,双引号都可以。 echo (不像其他语言构造)不表现得像一个函数, 所以不能总是使用一个函数的上下文。 另外,如果你想给echo 传递多个参数, 那么就不能使用小括号。
echo 也有一个快捷用法,你可以在打开标记前直接用一个等号。在 PHP 5.4.0 之前,必须在php.ini 里面启用 short_open_tag 才有效。Ihave<?=$foo?>foo.
参数arg1
要输出的参数
...返回值
没有返回值。
范例
Example #1 echo 例子
<?phpecho"HelloWorld";echo"Thisspansmultiplelines.Thenewlineswillbeoutputaswell";echo"Thisspansnmultiplelines.Thenewlineswillbenoutputaswell.";echo"Escapingcharactersisdone"Likethis".";//Youcanusevariablesinsideofanechostatement$foo="foobar";$bar="barbaz";echo"foois$foo";//fooisfoobar//Youcanalsousearrays$baz=array("value"=>"foo");echo"thisis{$baz['value']}!";//thisisfoo!//Usingsinglequoteswillprintthevariablename,notthevalueecho'foois$foo';//foois$foo//Ifyouarenotusinganyothercharacters,youcanjustechovariablesecho$foo;//foobarecho$foo,$bar;//foobarbarbaz//Somepeoplepreferpassingmultipleparameterstoechooverconcatenation.echo'This','string','was','made','withmultipleparameters.',chr();echo'This'.'string'.'was'.'made'.'withconcatenation.'."n";echo<<<ENDThisusesthe"heredocument"syntaxtooutputmultiplelineswith$variableinterpolation.Notethattheheredocumentterminatormustappearonalinewithjustasemicolon.noextrawhitespace!END;//Becauseechodoesnotbehavelikeafunction,thefollowingcodeisinvalid.($some_var)?echo'true':echo'false';//However,thefollowingexampleswillwork:($some_var)?print'true':print'false';//printisalsoaconstruct,but//itbehaveslikeafunction,so//itmaybeusedinthiscontext.echo$some_var?'true':'false';//changingthestatementaround?> 注释Note: 因为是一个语言构造器而不是一个函数,不能被可变函数 调用。
参见print - 输出字符串 printf() - 输出格式化字符串 flush() - 刷新输出缓冲 Heredoc 语法
PHP字符串函数count_chars()的用法 count_chars(PHP4,PHP5)count_chars返回字符串所用字符的信息说明mixedcount_chars(string$string[,int$mode=0])统计string中每个字节值(0..)出现的次数,使用多种模式返
PHP字符串函数convert_uuencode()的用法 convert_uuencode(PHP5)convert_uuencode使用uuencode编码一个字符串说明stringconvert_uuencode(string$data)convert_uuencode()使用uuencode算法对一个字符串进行编码。uuencode算法
PHP字符串函数convert_cyr_string()的用法 convert_cyr_string(PHP4,PHP5)convert_cyr_string将字符由一种Cyrillic字符转换成另一种说明stringconvert_cyr_string(string$str,string$from,string$to)此函数将给定的字符串从一种
标签: 在php中,字符串有哪些表示形式
本文链接地址:https://www.jiuchutong.com/biancheng/279866.html 转载请保留说明!友情链接: 武汉网站建设