php removes backslashes added by addcslashes() function stripcslashes()

黄舟
Release: 2023-03-17 06:26:01
Original
1586 people have browsed it

Example

Remove the backslash in front of "World!":

<?php
echo stripslashes("Hello World!");
?>
Copy after login

Definition and usage

stripcslashes() Function Remove backslashes added by the addcslashes() function.

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

Syntax

stripcslashes(string)
Copy after login
ParametersDescription
string Required. Specifies the string to be checked.

Technical details

Return value: Returns the unescaped string.
PHP version: 4+
##In addition, using the

addslashes function also "'" can be escaped directly.

The example is as follows:

<?php
$sql = "update book set bookname=&#39;let&#39;s go&#39; where bookid=1";
 echo $sql."<br/>";
 $new_sql = addcslashes($sql,"&#39;");
 echo $new_sql."<br/>";
 $new_sql_01 = stripcslashes($new_sql);
 echo $new_sql_01."<br/>";
 echo addslashes($sql);
?>
Copy after login

The running result is as follows:

update book set bookname=&#39;let&#39;s go&#39; where bookid=1
update book set bookname=\&#39;let\&#39;s go\&#39; where bookid=1
update book set bookname=&#39;let&#39;s go&#39; where bookid=1
update book set bookname=\&#39;let\&#39;s go\&#39; where bookid=1
Copy after login

The above is the detailed content of php removes backslashes added by addcslashes() function stripcslashes(). 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