Blogger Information
Blog 38
fans 1
comment 0
visits 26114
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP基础和虚拟机主机的搭建--2018年08月22日14时30分
一根火柴棒的博客
Original
711 people have browsed it

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


实例

<?php

header("content-type:text/html;charset=utf-8");

//变量解析:
$name = '张三';
$toDo = '吃饭';
echo $name.$toDo,'<br>';


//特殊字符转义:
$test = '特殊转义字符-斜杆:\\\n转移字符\'';

echo $test;

echo '<hr>';

//heredoc和nowdoc语法结构的用法

//heredoc 等价于 使用了双引号的字符串

//直接输出

//echo <<< HEREDOC 中间不要有空格
echo<<<HEREDOC
{$test}
HEREDOC;



//nowdoc 等价于 使用了单引号的字符串

//echo <<< NOWDOC 中间不要有空格
echo<<<'NOWDOC'

<h3>单引号</h3>

NOWDOC;



?>

运行实例 »

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

手写作业:

1. 手写: 变量的命名规则;

2. 手写: Web服务器访问原理;

3. 手写: 创建本地虚拟主机的过程(以你的工具为准)

0821手抄作业.jpg

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