Application examples of stripslashes and addslashes in php_PHP tutorial

PHP中文网
Release: 2016-07-20 11:03:10
Original
1247 people have browsed it

First test whether magic_quotes_gpc is ON. If so, use array_map() to recursively restore the escaped data. Whether the automatic addslashes function is turned on, we can check it by checking it in php.ini or use the get_magic_quotes_gpc() function.

<?php
// 说明: 用 stripslashes 还原 addslashes 转义后的数据
if(get_magic_quotes_gpc())
{
    function stripslashes_deep($value)
    {
        $value = is_array($value) ? array_map(&#39;stripslashes_deep&#39;, $value) : (isset($value) ? stripslashes($value) : null);
        return $value;
    }
 
    $_POST = stripslashes_deep($_POST);
    $_GET = stripslashes_deep($_GET);
    $_COOKIE = stripslashes_deep($_COOKIE);
}
?>
Copy after login

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template