String Functions

PHP stripslashes() Function

Topic: PHP String ReferencePrev|Next


The stripslashes() function removes backslashes added by the addslashes() function.

The following table summarizes the technical details of this function.

Return Value: Returns a string with backslashes stripped off.
Version: PHP 4+


The basic syntax of the stripslashes() function is given with:


The following example shows the stripslashes() function in action.

// Sample string
$str = "Mr. John O\'Reilly";

// Unescaping string
echo stripslashes($str);

Tip: The stripslashes() function strips off backslashes from a string in such a way that \' becomes ' and so on. Double backslashes (\\) becomes a single backslash (\).


The stripslashes() function accepts the following parameters.

Parameter Description
string Required. Specifies the string to be unescaped.

More Examples

Here're some more examples showing how stripslashes() function actually works:

The following example demonstrates how to escape and unescape a string.

// Sample string
$str = "C:\Users\Downloads";

// Escaping string
$escaped = addslashes($str);
echo $escaped . "<br>";

// Unescaping string
$unescaped = stripslashes($escaped);
echo $unescaped;
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties