首页 > 文章列表 > PHP中的addcslashes()函数

PHP中的addcslashes()函数

php 函数 addcslashes
266 2023-08-27

The addcslashes() function returns the string with blackslashes.

Note − The addcslashes() function is case-sensitive

Syntax

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

输出

以下是输出 −

First World!