How to remove backslash in php

藏色散人
Release: 2023-03-04 07:10:02
Original
3919 people have browsed it

How to remove backslashes in php: First open the corresponding PHP file; then remove the backslashes through the "stripslashes($_POST['json']);" method.

How to remove backslash in php

Recommended: "PHP Video Tutorial"

PHP removes backslashes in json strings \

The json string passed to PHP through AJAX is sometimes escaped with a backslash "\". During PHP processing, the backslash needs to be removed first and then json_decode.

$str = stripslashes($_POST['json']);
 
$arr = json_decode($str,true);
Copy after login

Related introduction:

stripslashes() function removes the backslashes added by the addslashes() function.

Tip: This function can be used to clean data retrieved from the database or from an HTML form.

Grammar

stripslashes(string)
Copy after login

The above is the detailed content of How to remove 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!