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

The syntax of the very helpful addslashes method is below:

Also Read This πŸ‘‰   php copyfile - PHP Copy File from One Folder to Another Example

addslahes ('string')

Free Live Chat for Any Issue


Name Description Required /
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>

$results = addslashes('What does "Papega" mean?');



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


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

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

Example 1 with demo

// PHP Example to demonstrate the 

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

// prints the escaped string 


Papega whatsappweb \"xname\"

Example 2 with demo

// PHP Example to demonstrate the  

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

// prints the escaped string 



Also you can learn more Reference:

Also Read This πŸ‘‰   sql subquery multiple tables Example
Web Programming Tutorials Example with Demo

Read :


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 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.