Removed duplicated info, and pointed users to the security section

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@173482 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Aidan Lister 2004-11-25 02:47:54 +00:00
parent 4f23d0c232
commit 6cf048bf21

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<!-- $Revision: 1.14 $ -->
<!-- splitted from ./en/functions/info.xml, last change in rev 1.2 -->
<refentry id="function.get-magic-quotes-gpc">
<refnamediv>
@ -58,38 +58,8 @@ $sql = "INSERT INTO lastnames (lastname) VALUES ('$lastname')";
</example>
</para>
<para>
In the interests of writing portable code (code that works
in any environment), or, if you do not have access to change
php.ini, you may wish to disable the effects of magic quotes
on a per-script basis. This can be done in two ways, with a
directive in a &htaccess; file (php_value magic_quotes_gpc 0),
or by adding the below code to the top of your scripts.
<example>
<title>Disabling magic quotes at runtime</title>
<programlisting role="php">
<![CDATA[
<?php
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
?>
]]>
</programlisting>
</example>
Magic-quotes was added to reduce code written by beginners from being dangerous.
If you disable magic quotes, you must be very careful to protect yourself from
SQL injection attacks.
For more information about magic_quotes, see this
<link linkend="security.magicquotes">security section</link>.
</para>
<simpara>
See also <function>addslashes</function>,