PHP 中的 addcslashes() 函数
phpprogrammingserver side programming更新于 2025/9/9 13:20:00
addcslashes() 函数返回带有黑斜杠的字符串。
注意 − addcslashes() 函数区分大小写
语法
addcslashes(str, characters)
参数
str − 要转义的字符串
characters − 要转义的字符或字符范围
返回
addcslashes() 函数返回在指定字符前带有反斜杠的字符串。
示例
以下是示例 −
<?php
$str = addcslashes("First World!","W");
echo($str);
?>
输出
以下是输出 −
First \World!
示例
让我们看另一个例子 −
<?php
$str = addcslashes("First World!","a..r");
echo($str);
?>
输出
以下是输出 −
F\i\rst W\o\r\l\d!

