Blogger Information
Blog 8
fans 0
comment 0
visits 3596
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php环境搭建与基本语法2018年-8月-22日
玩美者传媒的博客
Original
597 people have browsed it

实例演示php中的字符串中的变量解析,特殊字符转义,以及heredoc和 nowdoc语法结构的用法

<?php
/**
 * Created by PhpStorm.
 * User: lihanwen
 * Date: 2018/8/22
 * Time: 下午5:05
 */
$PeterZhu = '朱老师';
$mac ='MAC';
$shuiYi ='暂时没时间';
$wuLiao = "{$PeterZhu}为什么不录制个\'MAMP\'的使用教程,难到是看不起用{$mac}的,据我所知你本人也是用的{$mac}哦!";
$title = '不会不知道自己百度吗?';
$title1 = '我也是怎么想的,可没时间'.$shuiYi.'还有工作,';
$title2 = '这不是借口,不能全靠老师,';

echo $wuLiao, '<br>', $title, '<br>', $title1, '<br>', $title2;
echo '<hr>';
echo  <<< "HEREDOC"
{$wuLiao} 
HEREDOC;
echo <<< 'NOWDOC'
{$title1} 
<h1>老师我看不到这段代码的执行结果,应该没有问题</h1>
NOWDOC;

运行实例 »

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

手抄图

WechatIMG1925.jpeg

Correction status:qualified

Teacher's comments:注意:heredoc和nowdoc与前面的<<<之间尽量不要留空格
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