Correction status:qualified
Teacher's comments:注意:这里的heredoc和nowdoc与前面的<<<符号之间不需要有空格的!
1、代码实践
<?php /** * 字符串 */ $money = '95亿美元'; $title = '阿里'.$money.'收购了饿了么'; //.语法叫字符串的拼接符,连接符。 $title1 = "阿里{$money}收购了饿了么"; $title2 = '阿里{$money}收购了饿了么'; $title3 = "阿里{$money}收购了\"饿了么\""; $title4 = '阿里{$money}收购了\'饿了么\''; $title5 = "阿里{$money}收购了\\'饿了么\'"; echo $title; echo '<hr>'; echo $title1; echo '<hr>'; echo $title2; echo '<hr>'; echo $title3; echo '<hr>'; echo $title4; echo '<hr>'; echo $title5; echo '<hr color="pink">'; //heredoc //heredoc 等价使用了双引号的字符中,可以解析内部的变量和转义特殊字符 echo <<< HEREDOC {$title1} \n \r \t HEREDOC; echo '<hr color="red">'; //nowdoc //相当于用单引号包装的字符串 echo <<< 'NOWDOC' {$title2} \n \r \t <h3><a href="">hello 同学们晚上好呀!</a></h3> NOWDOC;
点击 "运行实例" 按钮查看在线实例
2、实例截图
3、手抄截图
4、学习小结
学习PHP变量名的命名规则,变量名严格区分大小区,函数不区分大小写