note 94758 added to function.stripslashes
| From: | eugene at ultimatecms dot co dot za | Date: | Mon, 23 Nov 2009 13:03:13 +0000 |
| Subject: | note 94758 added to function.stripslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163186@lists.php.net to get a copy of this message | ||
This is a simple function to remove the slashes added by functions such as magic_quotes_gpc and
mysql_escape_string etc.
<?php
function no_magic_quotes($query) {
$data = explode("\\",$query);
$cleaned = implode("",$data);
return $cleaned;
}
// I'm using mysql_escape_string as a simple example, but this function would work for any
escaped string.
$query = "It's amaizing! Who's to say this isn't a simple function?";
$badstring = mysql_escape_string($query);
echo '<b>Without funtion:</b> '.$badstring;
echo '<br><br>';
echo '<b>With function:</b> '.no_magic_quotes($badstring);
?>
Output:
Without funtion: It\'s amaizing! Who\'s to say this isn\'t a simple function?
With function: It's amaizing! Who's to say this isn't a simple function?
----
Server IP: 69.147.83.197
Probable Submitter: 196.25.255.214
----
Manual Page -- http://www.php.net/manual/en/function.stripslashes.php
Edit -- https://master.php.net/note/edit/94758
Del: integrated -- https://master.php.net/note/delete/94758/integrated
Del: useless -- https://master.php.net/note/delete/94758/useless
Del: bad code -- https://master.php.net/note/delete/94758/bad+code
Del: spam -- https://master.php.net/note/delete/94758/spam
Del: non-english -- https://master.php.net/note/delete/94758/non-english
Del: in docs -- https://master.php.net/note/delete/94758/in+docs
Del: other reasons-- https://master.php.net/note/delete/94758
Reject -- https://master.php.net/note/reject/94758
Search -- https://master.php.net/manage/user-notes.php