Home  >  Article  >  Backend Development  >  PHP addslashes function for filtering strings

PHP addslashes function for filtering strings

巴扎黑
巴扎黑Original
2016-12-01 11:23:081752browse

For data security and preventing injection, it is necessary to filter the string obtained by $_GET. At first, I wrote a filtering function by myself. Later, I saw a filtering function that comes with PHP, so I recommended addslashes to everyone.
An example of using addslashes() is when you are entering data into a database. For example, inserting the name O'reilly into the database requires escaping it. Most databases use as escape character: O'reilly. This puts the data into the database without inserting extra . When the PHP directive magic_quotes_sybase is set to on, it means that inserting ' will be escaped with '.
Example:

 


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn