Home  >  Article  >  Backend Development  >  How to remove backslash in php

How to remove backslash in php

藏色散人
藏色散人Original
2020-08-08 10:53:093993browse

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);

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)

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!

Statement:
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