What is the escape character backslash in php

(*-*)浩
Release: 2023-02-25 21:04:01
Original
10919 people have browsed it

转义字符,顾名思义会将规定的语法用"\"(反斜杆)来输出。

What is the escape character backslash in php

但语法规定在不同的系统中转义字符的作用不同,例如:windows下的回车换行符用"\r"或"\n",而Linux 这两就有很大的区别:"\r"光标回到行首,但还在本行; "\n"表示下一行,不会回到行首。  (推荐学习:PHP视频教程

PHP中的转义字符有:

" \n" ==>换行
"\r"==>回车
"\t"==>水平制表符
"\\"==> 反斜杠
"\$" ==>美元符号
" \' "==>单引号
" \" " ==>双引号
" \[0-7]{1,3} " 正则表达式匹配一个八进制符号表示的字符
" \x[0-9A-Fa-f]{1,2} " 正则表达式匹配一个十六进制符号表示的字符
Copy after login

通过在有问题的字符前面放置一个反斜杠,对它进行转义:

echo "She said,\"How are you?\" ";
 
print 'I\'m just ducky.';
Copy after login

引号中的转义字符:双引号将用变量的值(test)代替它的名称($var),并用特殊字符表示的值($)代替它的代码(\$)。

单引号总是准确地打印你输入的内容,除了转义的单引号(\')和转义的反斜杠(\\)之外,它们将分别被打印为一个单引号和一个反斜杠。

The above is the detailed content of What is the escape character backslash in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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