PHP removes the backslash function added by the addslashes () function stripslashes ()

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.