String Functions
Advertisements

PHP stripslashes() Function

Topic: PHP String ReferencePrev|Next

Description

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+

Syntax

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

stripslashes(string);

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

<?php
// 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 (\).


Parameters

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.

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

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


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