Blogger Information
Blog 34
fans 0
comment 0
visits 32341
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
变量命名规则+web服务器访问原理+本地虚拟主机创建步骤+字符串中的变量解析,字符转义,heredoc,nowdoc
Belifforz的博客
Original
753 people have browsed it

实例

<?php
//字符串

$grade1 = '95';
$grade2 = '80';
$grade3 = '76';
$title1 = '小明今天数学考试得了'.$grade1.'分';
$title2 = '小明今天数学考试得了\'$grade2分\'';
$title3 = "小明今天数学考试得了{$grade3}\\\"分\"";

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

echo '<hr>';

//heredoc
// heredoc 等价使用了双引号的字符中,可以解析内部的变量和转义特殊字符
echo  <<< "HEREDOC"
{$title2} \n  \r \t 
这和双引号没什么区别,可以直接输出出来
HEREDOC;
echo '<hr>';
// nowdoc
// 相当于用单引号包装的字符串
echo <<< 'NOWDOC'
{$title2} \n  \r \t
<h3><a href="">Hello 同学们晚上好呀</a></h3>
NOWDOC;

运行实例 »

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

QQ截图20180822105450.png


QQ截图20180822104615.png

Correction status:qualified

Teacher's comments:
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