PHP parsing inbound and outbound libraries

Source: Internet
Author: User

Reprint: http://www.jb51.net/article/39092.htm

What to look for when data is put into the database and taken out to display on the page
When in storage
$str =addslashes ($STR);
$sql =\ "INSERT INTO ' tab ' (' Content ') VALUES (\ ' $str \ ') \";
When you are out of the library
$str =stripslashes ($STR);
when displayed
$str =htmlspecialchars (NL2BR ($STR));
<?
//--title, name and other fields for inbound processing (go-to spaces)
Functiontrans_string_trim ($STR) {
$str =trim ($STR);
$str =eregi_replace ("'", "'", $str);
$str =stripslashes ($STR);
RETURN$STR;
}
//--Article warehousing processing, that is, the textarea field;
Functiontrans_string ($STR) {
$str =eregi_replace ("'", "'", $str);
$str =stripslashes ($STR);
RETURN$STR;
}
//--is displayed in the form from the library, in the text in the trans, in the textarea, without conversion, directly display
--Displays the Web page, filters the HTML code, including the link address
Functiontrans ($string) {
$string =htmlspecialchars ($string);
$string =ereg_replace (CHR), "<br>", $string);
$string =ereg_replace (CHR), "", $string);
return$string;
}
--Display in Web page, do not filter HTML code;
Functiontrans_web ($string) {
$string =ereg_replace (CHR), "<br>", $string);
$string =ereg_replace (CHR), "", $string);
return$string;
}
//--Display in Web pages, filtering HTML code and trailing spaces, primarily for displaying user nicknames
Functiontrans_trim ($string) {
$string =trim ($string);
$string =htmlspecialchars ($string);
$string =ereg_replace (CHR), "<br>", $string);
$string =ereg_replace (CHR), "", $string);
return$string;
}
//--displayed in span;
Functiontrans_span ($string) {
$string =ereg_replace (CHR), "\ n", $string);
$string =ereg_replace (CHR), "", $string);
$string =ereg_replace (' "'," "" ", $string);
return$string;
}
//--Display cookies on the web, filtering HTML
Functiontrans_cookie ($STR) {
$str =trans ($STR);
$str =stripslashes ($STR);
$str =eregi_replace ("'" "," ' ", $str);
RETURN$STR;
}
?>

PHP parsing inbound and outbound libraries

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.