note 97215 added to function.htmlentities
| From: | phil at lavin dot me dot uk | Date: | Thu, 08 Apr 2010 15:34:20 +0000 |
| Subject: | note 97215 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-168032@lists.php.net to get a copy of this message | ||
The following will make a string completely safe for XML:
<?php
function philsXMLClean($strin) {
$strout = null;
for ($i = 0; $i < strlen($strin); $i++) {
$ord = ord($strin[$i]);
if (($ord > 0 && $ord < 32) || ($ord >= 127)) {
$strout .= "&#{$ord};";
}
else {
switch ($strin[$i]) {
case '<':
$strout .= '<';
break;
case '>':
$strout .= '>';
break;
case '&':
$strout .= '&';
break;
case '"':
$strout .= '"';
break;
default:
$strout .= $strin[$i];
}
}
}
return $strout;
}
?>
----
Server IP: 92.48.74.199
Probable Submitter: 80.229.71.19
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/97215
Del: integrated -- https://master.php.net/note/delete/97215/integrated
Del: useless -- https://master.php.net/note/delete/97215/useless
Del: bad code -- https://master.php.net/note/delete/97215/bad+code
Del: spam -- https://master.php.net/note/delete/97215/spam
Del: non-english -- https://master.php.net/note/delete/97215/non-english
Del: in docs -- https://master.php.net/note/delete/97215/in+docs
Del: other reasons-- https://master.php.net/note/delete/97215
Reject -- https://master.php.net/note/reject/97215
Search -- https://master.php.net/manage/user-notes.php