Because leaving it makes you write more secure code.
If Mr. O'Malley leaves to register on your site, magic_quotes_gpc will turn his last name into O \ Malley, and when you insert it into the database, everything will be fine.
The problem is that magic_quotes come from addlashes - which doesn't necessarily work like escaping for your database system. O'Malley may work, but it is also possible to bypass this escaping and perform SQL injection.
If magic_quotes is not enabled, you will get an O'Malley string and it will break the SQL statement, for example
INSERT INTO users (...) VALUES (...,'O'Malley',...)
Note that the line actually ends after O.
In addition, this is better: if you, for example, sent an email with his name, you would have to do strip flippers - for no reason. If you do not, you will receive an email from Mr. O'Malley.
(Of course, for REALLY safe database processing code, you want to use parameterized queries, as this is the best way to prevent SQL injection. And if you parameterize, you do not want the slash anyway, and it is a waste of time to add PHP .)
source share