PHP JSON string pair special character processing (single quotes, double quotes) _php Tutorial

Source: Internet
Author: User
Tags form post php json

PHP JSON string to special character processing (single quotation marks, double quotes)


Preface: Form form Post,get and so on to submit data to the background, the background with PHP to receive the submitted data contains "" "," "", "\" (double quotes, single quotes, backslashes), the new version of PHP (MAGIC_QUOTES_GPC when the php.ini is set to ON, Automatic addslashes () is escaped. 5.3 Obsolete, 5.4 removal, all need to be escaped with addslashes (), you need to add escape with addslashes (). PHP accepts the form form submitted by the data, you need to escape with stripcslashes () after escaping with Addslashes (), and then insert the database. Use Addslashes () to escape the data stored in the database, take out, the same: need to be escaped with stripcslashes (), and then use Json_encode () to convert the required data to JSON format, and then escape with Addslashes () back to JS, Let JS processing. Note: Json_decode (string,true) is converted to an object form in this way directly to the data to be parsed, and not later to true. Default is False

http://www.bkjia.com/PHPjc/1060169.html www.bkjia.com true http://www.bkjia.com/PHPjc/1060169.html techarticle PHP JSON string to special character processing (single quotation mark, double quotation mark) Preface: Form table is submitted data to backstage with Post,get and so on, background with PHP to receive submitted data contains,, \ (double quotes, ... )

  • Related Article

    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.