首頁  >  文章  >  後端開發  >  PHP中的addcslashes()函數

PHP中的addcslashes()函數

王林
王林轉載
2023-08-25 17:01:12890瀏覽

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中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除