Home > Backend Development > PHP Tutorial > PHP self-study no00006 data type string escape character

PHP self-study no00006 data type string escape character

WBOY
Release: 2016-07-29 08:51:00
Original
995 people have browsed it

<!--转义字符在字符串输出时需要通过转义符“\”来显示-->
<!--使用单号号时,原样输出只需要对单引号“&#39;”“\”转义-->
<!--使用双引号时,输出需要注意转义字符前加转义符“\”-->
<?php //前面的序号只为分清运行结果
	echo &#39;1\n&#39;;		//单引号原样输出
	echo "2\n";		//双引号换行
	echo &#39;3\r&#39;;		
	echo "4\r";		//回车
	echo &#39;5\t&#39;;
	echo "6\t";		//水平制表符
	echo &#39;7\\&#39;;		//输出一个反斜杠
	echo "8\\";		//输出一个反斜杠
	echo &#39;9\$&#39;;		//一个反斜杠加美元符
	echo "10\$";		//输出美元符
	echo &#39;11\&#39;&#39;;		//单引号
	echo "12\&#39;";		//反斜杠加单引号
	/*这里的单引号双引号自己老是搞不清,所以想了个办法,
	转义符\是警察,单引号是自卫男,双引号是痴情女。
	单引号自卫男只对自已&#39;和警察\这二个符号转义
	双引号痴情女其它都转义就是不理自卫男&#39;不转义
	
	*/
	echo &#39;13\"&#39;;		//输出一个斜杠一个双引号
	echo "14\"";		//输出一个双引号
	echo &#39;15\[0-7]{1,3}&#39;;
	echo "16\[0-7]{1,3}";
	echo &#39;17\x[0-9A-Fa-f]{1,2}&#39;;
	echo "18\x[0-9A-Fa-f]{1,2}";
?>
Copy after login

PHP self-study no00006 data type string escape character

以上就介绍了PHP self-study no00006 data type string escape character,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template