首页后端开发PHPphp数据字符转义字符 php转义字符函数

php数据字符转义字符 php转义字符函数

时间2023-04-05 22:30:01发布访客分类PHP浏览521
导读:php转义字符 用来表示一些如法输入的字符,或者输入后不明显,或者容易被编辑器替换的字符。例如:\r表示回车\n表示换行\$表示一个$符号,直接在PHP的字符串里面写$容易被误会为变量。php转义字符,斜杠、艾特符和and符 对我来说Or...

php转义字符

用来表示一些如法输入的字符,或者输入后不明显,或者容易被编辑器替换的字符。

例如:

\r表示回车

\n表示换行

\$表示一个$符号,直接在PHP的字符串里面写$容易被误会为变量。

php转义字符,斜杠、艾特符和and符

对我来说Or the dream factory has always been the high standard, the screen exquisite detail, vivid characters vivid, touching story twists and turns, the most important thing is it in the most simple and easy to understand that the way of a token, that is - there is no shortcut to the world and Cheats, the only winning Famen is believe in themselves.

这个杀手不太冷

This film was absolutely amazing. I have spent hours re-watching various scenes and noticing all the perfection with which they are acted and directed. It's not the violence or action sequences that make this movie so great (although they are well done...), but rather moments like where Mathilda knocks on Leon's door. It would be so easy to just film the door opening, but instead we see light illuminating Natalie Portman's face, symbolizing something angelic. And the moment has so much more meaning.

请问php中的转义字符是什么 能详细说一下吗

在php中:

* 以单引号为定界符的php字符串,支持两个转义\'和\\

* 以双引号为定界符的php字符串,支持下列转义:

\n 换行(LF 或 ASCII 字符 0x0A(10))

\r 回车(CR 或 ASCII 字符 0x0D(13))

\t 水平制表符(HT 或 ASCII 字符 0x09(9))

\\ 反斜线

\$ 美元符号

\" 双引号

\[0-7]{ 1,3} 此正则表达式序列匹配一个用八进制符号表示的字符

\x[0-9A-Fa-f]{ 1,2} 此正则表达式序列匹配一个用十六进制符号表示的字符

举几个例子:

一个包含\0特殊字符的例子:

$str = "ffff\0ffff";

echo(strlen($str));

echo("\n");

for($i=0; $istrlen($str); $i++)echo("\t".ord($str{ $i} ));

echo("\n");

输出结果:

----------------------

9

102 102 102 102 0 102 102 102 102

替换特殊字符的例子

$str = "ffff\0ffff";

$str = str_replace("\x0", "", $str);

//或者用$str = str_replace("\0", "", $str);

//或者用$str = str_replace(chr(0), "", $str);

echo(strlen($str));

echo("\n");

for($i=0; $istrlen($str); $i++)echo("\t".ord($str{ $i} ));

echo("\n");

输出结果:

----------------------

8

102 102 102 102 102 102 102 102

八进制ascii码例子:

//注意,符合正则\[0-7]{ 1,3} 的字符串,表示一个八进制的ascii码。

$str = "\0\01\02\3\7\10\011\08\8"; //这里的\8不符合要求,被修正为"\\8" (ascii为92和56)

echo(strlen($str));

echo("\n");

for($i=0; $istrlen($str); $i++)echo("\t".ord($str{ $i} ));

echo("\n");

输出结果:

----------------------

11

0 1 2 3 7 8 9 0 56 92 56

十六进制ascii码例子:

$str = "\x0\x1\x2\x3\x7\x8\x9\x10\x11\xff";

echo(strlen($str));

echo("\n");

for($i=0; $istrlen($str); $i++)echo("\t".ord($str{ $i} ));

echo("\n");

输出结果:

----------------------

10

0 1 2 3 7 8 9 16 17 255

PHP怎么把字符串里变成转义字符

编码

$new = htmlspecialchars("a href='test'Test/a", ENT_QUOTES);

echo $new; // a href='test'Test/a

解码

$str = 'pthis - "/p';

echo htmlspecialchars_decode($str);

// note that here the quotes aren't converted

echo htmlspecialchars_decode($str, ENT_NOQUOTES);

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: php数据字符转义字符 php转义字符函数
本文地址: https://pptw.com/jishu/2046.html
java十大装逼代码 java酷炫代码 php向数组里追加数据 php数组追加

游客 回复需填写必要信息