Blogger Information
Blog 22
fans 0
comment 0
visits 18107
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
【8/21】PHP初体验之变量相关规则以及helloword
花弄的博客
Original
725 people have browsed it

实例

<meta charset="utf-8">
<?php
$money = '95亿美元';
$titile = '阿里'.$money.'收购饿了么';

echo $titile;

$titile1 = '阿里'.$money.'收购\'饿了么\'';
echo '<br>'.$titile1;

$titile2 = "阿里{$money}收购\"饿了么\"";
echo '<br>'.$titile2;

$titile3 = "阿里{$money}收购\\\"饿了么\\\"";
echo '<br>'.$titile3;

//heardoc
//heardoc 邓嘉与使用了双引号的字符串中,可以解析内部的变量和转义特殊字符
$heardoc = <<< HEARDOC
$titile2
HEARDOC;

//nowdoc
//相当于用单引号包装的字符串
echo <<< 'NOWDOC'
	<h3><a href ="#"> hello,哈撒及啊</a></h3>
NOWDOC;
?>

运行实例 »

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

emm,这算是php初识的一点练习把,要注意的是变量的命名规范和命名的方法规则

task.jpg

理论知识还是要有的,不过实践出真知嘛。


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