search
Homephp教程php手册php 过滤字符串函数

php 过滤字符串函数

Jun 13, 2016 am 11:18 AM
functionphpreplacereturnstrfunctionstringfilter

 

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(); //除去字符串右边空格
 trim(); //除去字符串中所有空格
 ltrim(); //除去字符串左边空格 
 htmlspecialchars(); //转换'$','"',''为相应的html实体
 htmlentities(); //转换所有html标记为相应的html实体
 array explode(string separator, string str); //分割字符串
 string implode(string separator, array arr); //连接字符串
 strtoupper(); strtolower(); //转换大小写
 ucfirst(); //只转换第一个字符为大写
 ucwords(); //转换每个words的第一个字母为大写
iconv()
php内码转换函数,同上
因为iconv()在转换gb2312时的bug,所以要这样处理
iconv( "utf-8", "gb2312//ignore" , $str)

mb_convert_encoding()
php的内码转换函数
版本(php 4 >= 4.0.6, php 5)
这个函数可以将各种编码互相转换
mb_convert_encoding($str,"gb2312", "utf-8");


mysql教程_real_escape_string()
定义:函数转义 sql 语句中使用的字符串中的特殊字符。
语法: mysql_real_escape_string(string,connection)
说明:本函数将 string 中的特殊字符转义,并考虑到连接的当前字符集,因此可以安全用于 mysql_query()。
 ?>


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor