Blogger Information
Blog 14
fans 0
comment 0
visits 11110
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php基础知识变量规则和虚拟主机搭建--2018年08月21日作业
悦派的博客
Original
821 people have browsed it

实例

<?php
$C1="PHP";
$C2='中文网';
$C3='我正在';
$C4='学习';
$T1="好多同学在{$C4}";
echo $C1,'<br>',$C2;
echo '<hr>',$T1;
echo '<hr>',"{$C3}{$C1}{$C2}";
//heredoc
// heredoc 等价使用了双引号的字符中,可以解析内部的变量和转义特殊字符
echo <<<HEREDOC
{$T1},<br>这是一个双引号会解析里面的变量
HEREDOC;
// nowdoc
// 相当于用单引号包装的字符串
echo '<hr>';
echo <<<'NOWDOC'
这是一个单引号不会输出变量,{$T3}
NOWDOC;
?>

运行实例 »

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


121.jpg

总结

1、PHP是超文本预处理语言,HTML是超文本标记语言。php可以穿插在html文档任何位置

2、PHP中变量必须以$符开头,首字符不能是数字或下划线

3、PHP变量的命名常用驼峰法,即第一单词首字母小写,后续单词首字母都大写。目前最流行

4、php字符串一般用双引号或单引号,双引号可以解析变量{$str},单引号不能解析变量

5、heredoc语法相当于双引号,可以解析变量;nowdoc语法相当于单引号,不能解析变量


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
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!