magic-quotes

How can I disable PHP magic quotes at runtime?

荒凉一梦 提交于 2019-11-26 17:13:26
问题 I'm writing a set of PHP scripts that'll be run in some different setups, some of them shared hosting with magic quotes on (the horror). Without the ability to control PHP or Apache configuration, can I do anything in my scripts to disable PHP quotes at runtime? It'd be better if the code didn't assume magic quotes are on, so that I can use the same scripts on different hosts that might or might not have magic quotes. 回答1: Only magic_quoted_runtime can be disabled at runtime. But magic_quotes

Magic quotes in PHP

爱⌒轻易说出口 提交于 2019-11-26 12:15:31
问题 According to the PHP manual, in order to make code more portable, they recommend using something like the following for escaping data: if (!get_magic_quotes_gpc()) { $lastname = addslashes($_POST[\'lastname\']); } else { $lastname = $_POST[\'lastname\']; } I have other validation checks that I will be performing, but how secure is the above strictly in terms of escaping data? I also saw that magic quotes will be deprecated in PHP 6. How will that affect the above code? I would prefer not to