PHP addcslashes() Function

Syntax:


string addcslashes ( string $str , string $charlist )  
    

Function Parameters

Parameter Description Required/Optional
String String to be escaped Required
Character Character or range to be escaped Required

Example 1


<?php  
$str = "Welcome to SHORAT";  
echo "Your String: " . $str;  
echo "<br>By using 'addcslashes()' method your string: " . addcslashes($str, 'T') . "<br>";        
?>
            

Output

Your String : Welcome to SHORAT By using 'addcslashes()' method your string: Welcome to SHORAT

Example 2


<?php  
$str = "Welcome to SHORAT";  
echo "Your String: " . $str;  
echo "<br>By using 'addcslashes()' method your string: " . addcslashes($str, 'a') . "<br>"; 
?>
            

Output

Your String : Welcome to SHORAT By using 'addcslashes()' method your string: Welcome to SHORA

Example 3


<?php  
$str = "Welcome to SHORAT<br>";  
echo "$str";  
echo addcslashes($str, 'A..Z') . "<br>";
?>
            

Output

Welcome to SHORAT Welcome to SHORAT

Example 4


    <?php  
    $str = "Welcome to Shorat Innovation"."<br>";  
    echo "$str";  
    echo addcslashes($str, 'a..z')."<br>";   
    ?>
            

Output

Welcome to Shorat Innovation Welcome to Shorat Innovation<br>

Example 5


    <?php  
    $str = "Welcome to Shorat Innovations";  
    echo "Your string value is: " . $str . "<br>"; 
    echo "By using addcslashes() Function your value is : " . addcslashes($str, 'a..m');    
    ?>
            

Output

Your string value is: Welcome to Shorat Innovations By using addcslashes() Function your value is : Welcome to Shorat Innovations