Javatpoint Logo
Javatpoint Logo

PHP addslashes() Function

PHP addslashes() function is used to return a quote string with slashes. It works with some characters:

  • Single quote (')
  • Double quote(")
  • Blackslash(|)
  • NUL (the NUL byte)

Syntax:

Parameter Description Required/Optional
string String to be escaped Required

Example 1

Output:

Your string is :What does "WHO" mean?
By using addslashes() function the result isWhat does \"WHO\" mean?

Example 2

Output:

Who's the father of PHP? This is not safe in a database query.
Who\'s the father of PHP? This is safe in a database query.

Example 3

Output:

Wow' PHP?

A use case of addslashes() is escaping the abovementioned characters in a string that is to be evaluated by PHP:

Example 4

Output:

Is The Father of PHP\'Rasmus? 

Next TopicPHP String




Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA