Recently in the writing BBS, encountered code conversion problems. Looking for a long time, only to get a better solution, can completely restore the original text.
Here is a post for you to correct me.
System: linux+php4+oracle8i
?
--title, name and other fields of storage processing (go to the end of space)
function Trans_string_trim ($STR) {
$str =trim ($STR);
$str =eregi_replace ("" "," "" ", $str);
$str =stripslashes ($STR);
return $str;
}
--The article warehousing processing, namely textarea field;
function trans_string ($STR) {
$str =eregi_replace ("" "," "" ", $str);
$str =stripslashes ($STR);
return $str;
}
--displayed in the form from the library, in text with trans, in textarea, no conversion, direct display
--Display on a Web page, filter HTML code, include a link address
function trans ($string) {
$string =htmlspecialchars ($string);
$string =ereg_replace (CHR), "<br>", $string);
$string =ereg_replace (CHR), "", $string);
return $string;
}
--Display on Web page, do not filter HTML code;
function Trans_web ($string) {
$string =ereg_replace (CHR), "<br>", $string);
$string =ereg_replace (CHR), "", $string);
return $string;
}
--Display on Web page, filter HTML code and trailing space, mainly used to display user nickname
function Trans_trim ($string) {
$string =trim ($string);
$string =htmlspecialchars ($string);
$string =ereg_replace (CHR), "<br>", $string);
$string =ereg_replace (CHR), "", $string);
return $string;
}
--shown in span;
function Trans_span ($string) {
$string =ereg_replace (CHR), "/n", $string);
$string =ereg_replace (CHR), "", $string);
$string =ereg_replace ("" "," "", $string);
return $string;
}
--Display cookies on the Web, filter HTML
function Trans_cookie ($STR) {
$str =trans ($STR);
$str =stripslashes ($STR);
$str =eregi_replace ("" "," "", $str);
return $str;
}
?>
---------------------------
Finally, incidentally, if you show a paragraph in a span and use substr to set a long string, remember to add a space behind the parameters of the span, or you'll mess up the HTML code when you intercept half of the characters.