1
0
mirror of https://github.com/php/web-php.git synced 2026-04-29 01:43:15 +02:00

Add FAQ about adding slashes via regular expression.

This commit is contained in:
James Gingerich
1998-06-15 23:20:44 +00:00
parent eeaa95ca0d
commit 31bd110b7c
+14
View File
@@ -382,6 +382,20 @@ http://leonard.staff.imaginet.fr/Doc/php/configuration_NT.html</a>.
while (list($var, $value) = each($HTTP_POST_VARS)) {
echo "$var = $value&lt;br&gt;\n";
}</PRE>
<P>
</DD>
<DT><B>
I need to convert all single-quotes (') to a backslash followed by
a single-quote. How can I do this with a regular expression?
</B></DT>
<DD>
First off, take a look at the <A href="manual/function.addslashes.php3">addslashes()</A> function. It will do
exactly what you want.
<P>
The ereg_replace magic you're looking for, however, is simply:<PRE>
$escaped = ereg_replace("'", "\\'", $input);</PRE>
<P>
</DD>
<DT><B>