A summary of escape characters

Source: Internet
Author: User
I recently encountered code conversion problems in writing bbs. After searching for a long time, we can get a perfect solution to completely restore the author's original article. The following post is for your correction. System: linux + php4 + oracle8i? // -- Input the title, name, and other fields into the database (with spaces at the beginning and end) functiontrans_string_trim ($ str) {$ strtrim ($ str); $ str is being written to bbs recently, code conversion problems. After searching for a long time, we can get a perfect solution to completely restore the author's original article.
The following post is for your correction.
System: linux + php4 + oracle8i

// -- Import the title, name, and other fields into the database (with spaces at the beginning and end)
Function trans_string_trim ($ str ){
$ Str = trim ($ str );
$ Str = eregi_replace ("'", "'' ", $ str );
$ Str = stripslashes ($ str );
Return $ str;
}

// -- Process the input of an article, that is, the textarea field;
Function trans_string ($ str ){
$ Str = eregi_replace ("'", "'' ", $ str );
$ Str = stripslashes ($ str );
Return $ str;
}

// -- Display the data in the form from the library; convert the data in text to trans. in textarea, the data is directly displayed without conversion.

// -- Display the HTML code on the WEB page, including the link address
Function trans ($ string ){
$ String = htmlspecialchars ($ string );
$ String = ereg_replace (chr (10 ),"
", $ String );
$ String = ereg_replace (chr (32), "", $ string );
Return $ string;
}

// -- Display on the WEB page without filtering HTML code;
Function trans_web ($ string ){
$ String = ereg_replace (chr (10 ),"
", $ String );
$ String = ereg_replace (chr (32), "", $ string );
Return $ string;
}

// -- Display HTML code and leading and trailing spaces on the WEB page, mainly used to display user nicknames
Function trans_trim ($ string ){
$ String = trim ($ string );
$ String = htmlspecialchars ($ string );
$ String = ereg_replace (chr (10 ),"
", $ String );
$ String = ereg_replace (chr (32), "", $ string );
Return $ string;
}

// -- Display in span;
Function trans_span ($ string ){
$ String = ereg_replace (chr (10), "n", $ string );
$ String = ereg_replace (chr (32), "", $ string );
$ String = ereg_replace ('"'," ", $ string );
Return $ string;
}

// -- Display cookies on the WEB to filter html
Function trans_cookie ($ str ){
$ Str = trans ($ str );
$ Str = stripslashes ($ str );
$ Str = eregi_replace ("'' "," '", $ str );
Return $ str;
}
?>
---------------------------
Finally, add another note. if the section in the article is displayed in span and the fixed length string is obtained using substr, add a space after the span parameter, otherwise, html code will be messy when half of Chinese characters are captured.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.