In php, the addslashes () function adds a backslash before some predefined characters in the input string. the stripslashes () function deletes the backslash added by the addslashes () function. This article summarizes some usage and examples of
This article mainly introduces the differences between PHP stripslashes and addslashes, sharing the convenience of friends.
When we write data to MySQL, for example: The code is as follows: mysql_query ("Update table set ' title ' = ' Kuhanzhu ' s
In PHP we often use stripslashes and addslashes, let me explain in detail the stripslashes and addslashes use of the difference between them.
Addslashes
The Addslashes () function adds a backslash before the specified predefined character.
These
In php, we often use stripslashes and addslashes. next I will introduce the differences between stripslashes and addslashes in detail. The addslashes and addslashes () functions add a backslash before the specified predefined characters.
In php, we
The function of the addslashes () function and the stripslashes () function in PHP and some usage are described earlier in this article to introduce PHP
stripslashes () function and addslashes () functionThe difference.
they differ from the
This article mainly introduces the difference between PHP stripslashes and addslashes, sharing the convenience needs of friends. When we write data to MySQL, for example: The code is as follows: mysql_query ("Update table set ' title ' = '
PHP for security, so introduced a MAGIC_QUOTES_GPC = on function, you can directly put single quotation marks into the database without any processing, then for off, you need to consider the problem of single quotes, rather than blindly trust the
In php, we often use stripslashes and addslashes. Next I will introduce the differences between stripslashes and addslashes in detail.
Addslashes
The addslashes () function adds a backslash before the specified predefined character.
The predefined
When we write data to MySQL, for example:
Copy the Code code as follows:mysql_query ("Update table set ' title ' = ' Kuhanzhu ' s blog ')";That's going to go wrong. As with ASP, the database will be allergic to single quotes. And addslashes at this
In PHP, addslashes () and stripslashes () are used for string conversion and restoration. Examples of character string conversion and restoration using addslashes () and stripslashes () in PHP. Examples of this article describe the use of escape
When MAGIC_QUOTES_GPC = ON, using the addslashes () processed data in the database will be in the form of \ ', if the direct output at this time, you will find a more than the content of their expectations, so stripslashes (), it can put \ Remove
When we write data to MySQL, for example:
Copy Code code as follows:
mysql_query ("Update table set ' title ' = ' Kuhanzhu ' blog '");
That's going to go wrong. As with ASP, the database is allergic to single quotes. And
When we write data to mysql, for example:
Copy codeThe Code is as follows:Mysql_query ("update table set 'title' = 'kuhanzhu's blog '");Then an error occurs. Like asp, databases are allergic to single quotes. Addslashes has the longest face at this
PHP addslashes () and Stripslashes () implement string escape and restore usages, use of escape characters
Examples in this article describe the use of addslashes () and stripslashes () in PHP for string escaping and restoration. Share to everyone
AddslashesThe addslashes () function adds a backslash before the specified predefined character.The predefined characters are:• Single quotes (')• Double quotation marks (")• Backslash ()• NULLIn this example, we want to add a backslash to the
Http://yangjunwei.com/a/589.htmlPHP's own library functions Addslashes () and Stripslashes () are string-processing class functions that are the opposite:
Addslashes (): Adds a backslash to some of the predefined characters in the input
: This article mainly introduces examples of character string conversion and restoration usage of addslashes and stripslashes in PHP. For more information about PHP tutorials, see. The example in this article describes how to convert and restore
PHP functions quite a lot, to complete each function is very understanding is a very challenging thing.Strip_tags,htmlspecialchars,htmlentities,stripslashes,addslashes These functions I think I need a special reinforcement.First function: Strip_tags,
The Addslashes () function returns a string that adds a backslash before a predefined character.The predefined characters are:
Single quotation mark (')
Double quotation marks (")
Back slash (\)
Null
Echo "Who's Bill Gates?"
Examples in this article describe the use of addslashes () and stripslashes () in PHP for string escaping and restoration. Share to everyone for your reference, as follows:
The addslashes () function in PHP returns a string that adds a backslash
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.