Blogger Information
Blog 24
fans 0
comment 1
visits 14618
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0411课后作业
张成钢的博客
Original
526 people have browsed it

实例

<meta charset="utf-8">
<?php 
	// 1.单双引号的区别
	$name = '李嘉诚';
	$new1 = '$name是一个成功的商人!';
	echo $new1;

	echo "<br>";
	$new1 = "{$name}是一个成功的商人";
	echo $new1;
	echo '<hr>';

	// 2.转义符\的使用 定界符输出
	echo "<br>";
	echo '王阳明说:\'此心光明,亦复何言!\'';
	echo '<br>';
	echo "王阳明说:\"此心光明,亦复何言!\"";
	echo '<br>';
	echo '王阳明说:"此心光明,亦复何言!"';
	
	echo '<hr>';

	// 3.输出特殊转义字符
	// 3.1自身
	echo '<br>';
	echo '<hr>';
	echo "王阳明说:\"此心光明,亦复何言!\"\\";

	// 3.2换行符
	echo '<br>';
	echo "王阳明说:\n\"此心光明,亦复何言!\"";

	// 3.3回车符
	echo '<br>';
	echo "王阳明说:\r\"此心光明,亦复何言!\"";

	// 3.4制表符
	echo '<br>';
	echo "王阳明说:\t\"此心光明,亦复何言!\"";

	// 3.5美元符号
	echo '<br>';
	echo "王阳明说:\$\"此心光明,亦复何言!\"";

	echo '<hr>';

	// 王阳明说:你未看此花时,此花与汝心同归于寂,你来看此花时,则此花颜色一时明白起来。
	//4 <<< 界定符
	$myDoc = <<< MYDOC1
    王阳明说:\n"你未看此花时,此花与汝心同归于寂,你来看此花时,则此花颜色一时明白起来。"
MYDOC1;

	echo $myDoc;

	echo '<hr>';
	//4.2  nl2br 函数替换\n 插入<br> 换行
	echo nl2br($myDoc);
	echo '<hr>';

	//4.3 原样输出变量、特殊字符、转义符  用单引号
	$myDoc2 = <<< 'MYDOC2'
	<h2>$name</h2> \r\n '王阳明心学'
MYDOC2;

	echo $myDoc2;
	echo '<hr>';
 ?>

运行实例 »

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


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!