Blogger Information
Blog 22
fans 0
comment 0
visits 14826
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
web服务器的访问原理和创建本地虚拟主机的过程,php中变量的命名规则, 字符串中的变量解析,特殊字符转义以及heredoc、nowdoc语法的结构和用法 2018-8-22 22:00
朝闻道的博客
Original
542 people have browsed it

代码如下:

实例

?php
//字符串

$money = '3000万RMB';
//$title1 = 'php中文网'.$money.'收购了php study';
$title1 = 'php中文网$money收购了\'php study\'';
$title2 = "php中文网{$money}收购了\\\"php study\"";

echo $title1, '<br>', $title2, '<br>';
echo nl2br($title2);

echo '<hr>';

//heredoc
// heredoc 等价使用了双引号的字符中,可以解析内部的变量和转义特殊字符
echo  <<< "HEREDOC"
{$title2} \n  \r \t 
HEREDOC;

// nowdoc
// 相当于用单引号包装的字符串
echo <<< 'NOWDOC'
{$title2} \n  \r \t
<h3><a href="">php中文网晚上好</a></h3>
NOWDOC;
?>

运行实例 »

点击 "运行实例" 按钮查看在线实例

手抄笔记照片:

IMG_20180822_133408.jpg


44cbac18fb4c934b.pngIMG_20180822_133550.jpg

Correction status:qualified

Teacher's comments:注意:代码中的heredoc和nowdoc与前面的<<<之间尽量不要给空格,头部的?php少了<符号
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