PHP 字符串函数

PHP stripcslashes() 函数它用于删除反斜杠,它返回一个去掉反斜杠的字符串。

它是addcslashes() 的反函数,这个函数 stripcslashes()在我们需要删除反斜杠时很重要。

语法

string stripcslashes ( string $str );

参数

参数说明必须/可选
string用来指定检查的字符串必须

示例

介绍2个例子,了解PHP stripcslashes() 函数的使用方法。

示例1

<?php
$str="Hello PHP\!";
echo "原字符串为:".$str;
echo "<br>";
echo "使用stripcslashes()函数后的字符串为:".stripcslashes($str);
?> 

输出:

原字符串为:Hello PHP\!
使用stripcslashes()函数后的字符串为:Hello PHP!

示例2

<?php
$string="Hello, we are Learning \PHP from yxjc123.";
echo "原字符串为: ".$string;
echo "<br>";
echo "使用stripcslashes()函数后的字符串为:".stripcslashes($string);
?>

输出:

原字符串为: Hello, we are Learning \PHP from yxjc123.
使用stripcslashes()函数后的字符串为:Hello, we are Learning PHP from yxjc123.