note 80561 deleted from function.addslashes by danbrown
| From: | danbrown@php.net | Date: | Thu, 20 Dec 2012 15:30:01 +0000 |
| Subject: | note 80561 deleted from function.addslashes by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192618@lists.php.net to get a copy of this message | ||
Note Submitter: Edwin at NOSPAM dot example dot com
----
In the note below of Adrian C (3-3-2007) checkaddslashes will not behave well with strings starting
with a single quote (because of the non-typed comparison) or with strings having a mix of escaped
and non-escaped single quotes.
Although addslashes also escapes double quotes, this function worked for single quotes fine.
<?php
function checkaddslashes($str){
$str2 = str_replace("\'", "*****", $str);
if(strpos($str2,"'")!== false)
return str_replace('*****', "\'", addslashes($str2));
else
return $str;
}
?>