PHP addslashes Function with Examples

The Core PHP addslashes method is used to some extra add slashes to explicit characters in a Data string. Those all the string characters are available ignore quotes on single quote (‘), double quote (“) or slash, as well as backslash symbol, the NULL empty character. This method is helpful when I try to added some data strings into a any type of the database Like as a MySQL. also you can learn my prev All about PHP Function. like as stripslashes, escape forward slash, escape special characters, php addslashes sql injection or many more.

There are the following the list of The predefined characters are:

  • single quote (‘)
  • double quote (“)
  • backslash (\)
  • NULL
Read Also:  How to show selected value from database in dropdown using Laravel?

The syntax of the very helpful addslashes method is below:

addslahes ('string')

Parameter:

Name Description Required /
Optional
Type
string_name The specified string. Required String

Return String values: The great escaped string Like as a python double slash.

escaped,python double slash,backslash symbol,ignore quotes,single quote
PHP addslashes Function with Examples

PHP addslashes() Function

simple defination included a backslash in front of available in each double quote (“):

<!DOCTYPE html>
<html>
<body>

<?php 
$results = addslashes('What does "Papega" mean?');
echo($results); 
?> 

</body>
</html>

results

What does \"Papega\" mean?

php addslashes not working,addslashes and stripslashes in php,php addslashes sql injection,addcslashes in php,php escape special characters,php escape forward slash,php escape single quote,php escape characters,
PHP addslashe Function

Examples:

Input : $string = "Pakainfo's"
Output : Pakainfo\'s

Input : $string='Papega whatsappweb "xname"'
Output : Papega whatsappweb \"xname\"

Example 1 with demo

<?php 
// PHP Example to demonstrate the 

// Input String 
$str = addslashes('Papega whatsappweb "xname"'); 

// prints the escaped string 
echo($str); 
?> 

Output:

Papega whatsappweb \"xname\"

Example 2 with demo

<?php 
// PHP Example to demonstrate the  

// Input String 
$str = addslashes("Pakainfo's"); 

// prints the escaped string 
echo($str); 
?> 

Output:

Pakainfo\'s

Also you can learn more Reference:http://php.net/manual/en/function.addslashes.php

Read Also:  PHP AJAX Live Search Box Autocomplete Using MySQL Database
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Manual: addslashes.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.