philip Thu Jul 24 04:48:10 2003 EDT
Modified files:
/phpdoc/en/reference/strings/functions stripslashes.xml
addslashes.xml
Log:
Drastically increase descriptions and example uses, added an example, and
see also get_magic_quotes_gpc().
Index: phpdoc/en/reference/strings/functions/stripslashes.xml
diff -u phpdoc/en/reference/strings/functions/stripslashes.xml:1.2
phpdoc/en/reference/strings/functions/stripslashes.xml:1.3
--- phpdoc/en/reference/strings/functions/stripslashes.xml:1.2 Wed Apr 17 02:44:23
2002
+++ phpdoc/en/reference/strings/functions/stripslashes.xml Thu Jul 24 04:48:10
2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.stripslashes">
<refnamediv>
@@ -17,10 +17,35 @@
<para>
Returns a string with backslashes stripped off.
(<literal>\'</literal> becomes <literal>'</literal> and so on.)
- Double backslashes are made into a single backslash.
+ Double backslashes (<literal>\\</literal>) are made into a single
+ backslash (<literal>\</literal>).
+ </para>
+ <para>
+ An example use of <function>stripslashes</function> is when the PHP
+ directive <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link>
+ is <literal>on</literal> (it's on by default), and you aren't inserting
+ this data into a place (such as a database) that requires escaping.
+ For example, if you're simply outputting data straight from an HTML
+ form.
+ </para>
+ <para>
+ <example>
+ <title>A <function>stripslashes</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$str = "Is your name O\'reilly?";
+
+// Outputs: Is your name O'reilly?
+echo stripslashes($str);
+?>
+]]>
+ </programlisting>
+ </example>
</para>
<simpara>
- See also <function>addslashes</function>.
+ See also <function>addslashes</function> and
+ <function>get_magic_quotes_gpc</function>.
</simpara>
</refsect1>
</refentry>
Index: phpdoc/en/reference/strings/functions/addslashes.xml
diff -u phpdoc/en/reference/strings/functions/addslashes.xml:1.2
phpdoc/en/reference/strings/functions/addslashes.xml:1.3
--- phpdoc/en/reference/strings/functions/addslashes.xml:1.2 Wed Apr 17 02:44:13
2002
+++ phpdoc/en/reference/strings/functions/addslashes.xml Thu Jul 24 04:48:10
2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.addslashes">
<refnamediv>
@@ -19,15 +19,49 @@
(<literal>"</literal>), backslash (<literal>\</literal>)
and NUL (the &null; byte).
</para>
- <note>
- <para>
- <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> is ON by default.
- </para>
- </note>
+ <para>
+ An example use of <function>addslashes</function> is when you're
+ entering data into a database. For example, to insert the name
+ <literal>O'reilly</literal> into a database, you will need to escape
+ it. Most databases do this with a <literal>\</literal> which would
+ mean <literal>O\'reilly</literal>. This would only be to get the data
+ into the database, the extra <literal>\</literal> will not be inserted.
+ Having the PHP directive <link linkend="ini.magic-quotes-sybase">
+ magic_quotes_sybase</link> set to <literal>on</literal> will mean
+ <literal>'</literal> is instead escaped with another
+ <literal>'</literal>.
+ </para>
+ <para>
+ The PHP directive <link linkend="ini.magic-quotes-gpc">
+ magic_quotes_gpc</link> is <literal>on</literal> by default, and it
+ essentially runs <function>addslashes</function> on all GET, POST,
+ and COOKIE data. Do not use <function>addslashes</function> on
+ strings that have already been escaped with
+ <link linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> as you'll
+ then do double escaping. The function
+ <function>get_magic_quotes_gpc</function> may come in handy for
+ checking this.
+ </para>
+ <para>
+ <example>
+ <title>An <function>addslashes</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$str = "Is your name O'reilly?";
+
+// Outputs: Is your name O\'reilly?
+echo addslashes($str);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
<para>
See also <function>stripslashes</function>,
- <function>htmlspecialchars</function>, and
- <function>quotemeta</function>.
+ <function>htmlspecialchars</function>,
+ <function>quotemeta</function>, and
+ <function>get_magic_quotes_gpc</function>.
</para>
</refsect1>
</refentry>
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php