Home > Backend Development > PHP Problem > How to unescape strings in php

How to unescape strings in php

青灯夜游
Release: 2023-03-11 11:16:02
Original
3168 people have browsed it

In PHP, you can use the stripslashes() function to reverse-escape the string. This function can restore the escaped string and delete the backslash added by the addslashes() function. The syntax format is " stripslashes(string)"; this function returns the raw, unescaped string.

How to unescape strings in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php string reverse Escape

You can use the stripslashes() function, which can restore the escaped string and delete the backslashes added by the addslashes() function.

Syntax format:

stripslashes(string)
Copy after login

This function returns the original string without escaping, and the parameter string is the escaped string.

The example of restoring the escaped string is as follows:

<?php
$str = "I don&#39;t love you";
$str1 = addslashes($str);
echo $str1 . "<br />";
echo stripslashes($str1) . "<br />";
?>
Copy after login

The execution result of the above program is:

I don\&#39;t love you
I don&#39;t love you
Copy after login

Recommended learning: "PHP Video tutorial

The above is the detailed content of How to unescape strings in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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