Instance
To remove a backslash:
<?phpecho stripslashes ("Who's Peter Griffin?");? >
Definition and usage
The Stripslashes () function deletes a backslash added by the addslashes () function.
Tip: This function can be used to clean up data retrieved from a database or from an HTML form.
Grammar
Stripslashes (String)
Parameters |
Describe |
String |
Necessary. Specifies the string to check |
Technical details
return value: |
Returns the string that stripped the backslash. |
PHP version: |
4 + |
By default, PHP instruction MAGIC_QUOTES_GPC is on, and automatically runs Addslashes () for all GET, POST, and COOKIE data. This is for the security of the database. Some characters stored directly in the database are unsafe and they are:
Single quotation mark (')
Double quotation marks (")
Back slash (\)
Null
**************************************************************************************************************
The Addslashes () function adds a backslash before the specified predefined character. These predefined characters are:
Single quotation mark (')
Double quotation marks (")
Back slash (\)
Null
**************************************************************************************************************
Example of Addslashes ():
<?php$str = "Who ' s John Adams?"; Echo $str. "This was not safe in a database query.<br/>"; Echo addslashes ($STR). "This is safe in a database query."? >
Output:
Who ' s John Adams? This is the not safe in a database query. Who\ ' s John Adams? This is safe in a database query.
**************************************************************************************************************
The Stripslashes () function is a reverse operation of addslashes (), which is to delete the backslash added by the addslashes () function.
**************************************************************************************************************
Stripslashes () Example:
<?phpecho stripslashes ("Who\ 's John Adams?");? >
Output:
Who ' s John Adams?