PHP filter string Function _php Tutorial

Source: Internet
Author: User
Tags mysql tutorial
NL2BR (); N to


Addslashes (); Strips tutorial Lashes (); Escape special characters when working with database tutorials
Definition: the Addslashes () function adds a backslash before the specified predefined character.
Syntax: Addslashes (String)
Note: By default, PHP instruction MAGIC_QUOTES_GPC is on, and automatically runs Addslashes () for all get, post, and cookie data. Do not use Addslashes () for strings that have been MAGIC_QUOTES_GPC escaped, because this results in double-layer escaping. You can use the function GET_MAGIC_QUOTES_GPC () to detect this situation.
function Addslashes_str ($STR) {
$str =addslashes ($STR);
$str =str_replace ($str, ";", '; ');
return $str;
}
function Stripslashes_str ($STR) {
$str =stripslashes ($STR);
$str =str_replace ($str, '; ', ";");
return $str;
}
?>


Chop (); Remove the right space from the string
Trim (); Remove all spaces in a string
LTrim (); Remove the left space of a string
Htmlspecialchars (); Convert ' $ ', ' ' ', ' < ', ' > ' for the corresponding HTML entity
Htmlentities (); Convert all HTML tags to the appropriate HTML entity
Array explode (string separator, string str); Split string
String implode (string separator, array arr); Connection string
Strtoupper (); Strtolower (); Convert case
Ucfirst (); Convert only the first character to uppercase
Ucwords (); Convert the first letter of each words to uppercase
Iconv ()
PHP Internal code conversion function, IBID.
Because Iconv () is a bug when converting gb2312, this is how to handle
Iconv ("Utf-8", "Gb2312//ignore", $str)

Mb_convert_encoding ()
PHP's internal code conversion function
Version (PHP 4 >= 4.0.6, PHP 5)
This function can convert various encodings to each other
Mb_convert_encoding ($str, "gb2312", "utf-8");


MySQL Tutorial _real_escape_string ()
Definition: A function escapes special characters in a string used in an SQL statement.
Syntax: mysql_real_escape_string (string,connection)
Description: This function escapes special characters in a string and takes into account the current character set of the connection, so it can be used safely for mysql_query ().
?>


http://www.bkjia.com/PHPjc/445422.html www.bkjia.com true http://www.bkjia.com/PHPjc/445422.html techarticle function Addslashes_str ($str) {$str =addslashes ($str) $str =str_replace ($str,;,;); return $str;} function Stripslashes_str ($str) {$str =stripslashes ($str); $str =str_replace ($str,;,;. ...

  • Related Article

    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.