note 106834 added to function.str-replace
| From: | jwzumwalt at neatinfo dot com | Date: | Sat, 10 Dec 2011 18:23:27 +0000 |
| Subject: | note 106834 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185012@lists.php.net to get a copy of this message | ||
sqlite_escape_string() does not catch all HTML characters that may
conflict with a browser display. Notice the difference with the
custom routine below.
# php lib command
$str = "Advoid! /slashes\, 'single' and these <too>";
$str = sqlite_escape_string($str);
echo "<br>$str<br>";
# custom function
$str = "Advoid! /slashes\, 'single' and these <too>";
$str = clean($str);
echo "<br>$str<br>";
function clean($str) {
$search = array('&' , '"' , "'" ,
'<' , '>' );
$replace = array('&', '"', ''',
'<', '>' );
$str = str_replace($search, $replace, $str);
return $str;
}
Output:
Advoid! /slashes\, "single" and these
Advoid! /slashes\, 'single' and these <too>
----
Server IP: 69.147.83.197
Probable Submitter: 75.167.170.164
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- https://master.php.net/note/edit/106834
Del: integrated -- https://master.php.net/note/delete/106834/integrated
Del: useless -- https://master.php.net/note/delete/106834/useless
Del: bad code -- https://master.php.net/note/delete/106834/bad+code
Del: spam -- https://master.php.net/note/delete/106834/spam
Del: non-english -- https://master.php.net/note/delete/106834/non-english
Del: in docs -- https://master.php.net/note/delete/106834/in+docs
Del: other reasons-- https://master.php.net/note/delete/106834
Reject -- https://master.php.net/note/reject/106834
Search -- https://master.php.net/manage/user-notes.php