Home >Backend Development >PHP Tutorial >addcslashes() function in PHP

addcslashes() function in PHP

王林
王林forward
2023-08-25 17:01:121045browse

addcslashes() function in PHP

The addcslashes() function returns the string with blackslashes.

Note − The addcslashes() function is case-sensitive

Syntax

addcslashes(str, characters)

Parameters

  • str − The string to be escaped

  • characters − The character or character range to be escaped

Return value

addcslashes() function returns a backslash before the specified character String.

Example

The following is an example−

Real-time demonstration

<?php
   $str = addcslashes("First World!","W");
   echo($str);
?>

Output

The following is the output−

First \World!

Example

Let’s see another example−

Demonstration

<?php
   $str = addcslashes("First World!","a..r");
   echo($str);
?>

Output

Here is the output−

F\i\rst W\o\r\l\d!

The above is the detailed content of addcslashes() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete