特殊PHP字符列表

时间:2013-05-08 01:36:43

标签: php string

我的意思是双引号字符串中使用的转义字符。还有其他:

\r
\t
\n

3 个答案:

答案 0 :(得分:8)

是的!列表可以找到at the PHP documentation for double-quoted strings

  
      
  • \n:换行(ASCII或0x或0x0A(10))
  •   
  • \r:回车(ASCII或CR中的CR或0x0D(13))
  •   
  • \t水平制表符(ASCII中的HT或0x09(9))
  •   
  • \v垂直制表符(ASCII或VT中的0x0B(11))(自PHP 5.2.5开始)
  •   
  • \e转义(ESC中的ESC或0x1B(27))(自PHP 5.4.0开始)
  •   
  • \f换页(ASCII或FF中的FF或0x0C(12))(自PHP 5.2.5开始)
  •   
  • \\反斜杠
  •   
  • \$美元符号
  •   
  • \" double-quote
  •   
  • \[0-7]{1,3}与正则表达式匹配的字符序列是八进制表示法中的字符
  •   
  • \x[0-9A-Fa-f]{1,2}与正则表达式匹配的字符序列是十六进制表示法中的字符
  •   

答案 1 :(得分:4)

 ?\a ⇒ 7                 ; control-g, C-g
 ?\b ⇒ 8                 ; backspace, <BS>, C-h
 ?\t ⇒ 9                 ; tab, <TAB>, C-i
 ?\n ⇒ 10                ; newline, C-j
 ?\v ⇒ 11                ; vertical tab, C-k
 ?\f ⇒ 12                ; formfeed character, C-l
 ?\r ⇒ 13                ; carriage return, <RET>, C-m
 ?\e ⇒ 27                ; escape character, <ESC>, C-[
 ?\s ⇒ 32                ; space character, <SPC>
 ?\\ ⇒ 92                ; backslash character, \
 ?\d ⇒ 127               ; delete character, <DEL>

答案 2 :(得分:2)

您是否阅读了有关Double quoted strings的文档?

Sequence        Meaning
\n              linefeed (LF or 0x0A (10) in ASCII)
\r              carriage return (CR or 0x0D (13) in ASCII)
\t              horizontal tab (HT or 0x09 (9) in ASCII)
\v              vertical tab (VT or 0x0B (11) in ASCII) (since PHP 5.2.5)
\e              escape (ESC or 0x1B (27) in ASCII) (since PHP 5.4.0)
\f              form feed (FF or 0x0C (12) in ASCII) (since PHP 5.2.5)
\\              backslash
\$              dollar sign
\"              double-quote
\[0-7]{1,3}     the sequence of characters matching the regular expression is a character in octal notation
\x[0-9A-Fa-f]{1,2}  the sequence of characters matching the regular expression is a character in hexadecimal notation