2023-08-25

PHP中的addcslashes()函数

PHP中的addcslashes()函数

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);
?>
登录后复制

输出

以下是输出 −

F/i/rst W/o/r/l/d!
登录后复制

以上就是PHP中的addcslashes()函数的详细内容,更多请关注php中文网其它相关文章!

https://www.php.cn/faq/596674.html

发表回复

Your email address will not be published. Required fields are marked *