Blogger Information
Blog 12
fans 0
comment 0
visits 6621
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
string 字符串型-php学习第五课
虎哥的学习日志
Original
517 people have browsed it

1//单引号创建字符串,不会解析变量和转义字符

$str = 'php中文网';

echo $str;

//若单引号中出现单引号,需要对单引号中的单引号进行转义

$str = 'php中文网\'www.\\php\\.cn\'';

2//双引号创建字符串,双引号中的字符串可以解析变量和所有的转义字符

$str1="php\r\n\$\"中文网\"{$str}";//php(换行)$"中文网"php中文网

3,heredoc//与双引号创建的字符串相似,可以解析变量和所有的转义字符

$heredoc =<<<LIST        //php5.3以后,LIST需要加双引号"LIST",因为引入了nowdoc

<ul>

<li><a href="http://www.php.cn">$str1</a></li>

</ul>

LIST;//这个LIST是标识符,开头和结尾必须相同

4,nowdoc语法创建字符串,与单引号创建字符串相似,不会解析变量和转义字符

$nowdoc = <<<'EOD'

<ul>

<li><a href="http://www.php.cn">$str1_这里不会被解析</a></li>

</ul>

EOD;


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post