PHP escape characters

Source: Internet
Author: User
: This article mainly introduces PHP escape characters. if you are interested in the PHP Tutorial, refer to it. In many cases, escape errors may occur when you capture some text from a third party. Summarize some php built-in escape functions, as shown in

Function name

Meaning

Introduction

Htmlspecialchars

Convert the ampersand, single double quotation marks, greater than or less than sign into HTML format

& Convert &
""
'Convert'
<转成<
> Convert to>

Htmlentities ()

Convert all characters to HTML format

In addition to the above htmlspecialchars characters, the two-byte characters are also displayed as encoding.

Addslashes

Double quotation marks, backslash, and NULL plus backslash escape

The modified characters include single quotation marks ('), double quotation marks ("), backslash (\), and NULL.

Stripslashes

Remove backslash characters

Removes the backslash from the string. If there are two backslash lines in a row, remove one and leave one. If there is only one backslash, remove it directly.

Quotemeta

Add a reference symbol

Include. \ + * in the string *? [^] ($) And other characters are preceded by the backslash "\" symbol.

Nl2br ()

Convert line breaks

Strip_tags

Remove HTML and PHP tags

Remove any HTML and PHP tags in the string, including the contents between Mark blocking. Note: if the HTML and PHP tags of the string are incorrect, an error is returned.

Mysql_real_escape_string

Escape special characters in SQL strings

Escape \ x00 \ n \ r space \ '"\ x1a, which is very effective for processing multi-byte characters. Mysql_real_escape_string determines the character set, and mysql_escape_string does not need to be considered.

Base64_decode

Base64 decoding

Decodes MIME base64 encoded data.

Base64_encode

Base64 encoding

Use MIME base64 to encode data

Urldecode

URL decoding

Decodes the encoded URL string

Urlencode

URL encoding

Encode a URL string

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above section introduces PHP escape characters, including some content, and hopes to help those who are interested in PHP tutorials.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.