Friday, June 12, 2026
HomeLanguagesPHP stripcslashes() Function

PHP stripcslashes() Function

The stripcslashes() is an inbuilt function in PHP that is used to remove backslashes that were added to escape certain characters in a string. It reverses the effect of the addslashes() function. It recognizes the C-language characters, like \n, \r …, octal and hexadecimal representations.

Syntax

stripcslashes(string $string): string;

Parameter

This function accepts only single parameter which is described below:

  • $string: The input string from which you want to remove backslashes.

Return Value

The stripcslashes() function returns the escaped string from the unescaped string.

Program 1: The following program demonstrates the stripcslashes() Function.

PHP




<?php
$escaped_string
      "This is an example with \\'escaped\\' characters.";
$original_string = stripcslashes($escaped_string);
echo "Escaped String: $escaped_string<br>.\n";
echo "Original String: $original_string";
?>


Output

Escaped String: This is an example with \'escaped\' characters.<br>.
Original String: This is an example with 'escaped' characters.

Program 2: The following is another program that demonstrates the stripcslashes() Function.

PHP




<?php
$escaped_string
      "This is an example with \\'escaped\\' characters.";
$original_string = stripcslashes($escaped_string);
if ($escaped_string === $original_string) {
    echo 
    "String was not escaped: $original_string";
} else {
    echo 
    "String was escaped and then unescaped: $original_string";
}
?>


Output

String was escaped and then unescaped: This is an example with 'escaped' characters.

Reference: https://www.php.net/manual/en/function.stripcslashes.php

RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS