<? nl2br(); // to <br/>
addslashes(); strips教程lashes(); //對資料庫教程操作時,轉義特殊字元
定義:addslashes() 函數在指定的預定義字元前添加反斜線。
文法:addslashes(string)
注釋:預設情況下,php 指令 magic_quotes_gpc 為 on,對所有的 get、post 和 cookie 資料自動運行 addslashes()。不要對已經被 magic_quotes_gpc 轉義過的字串使用 addslashes(),因為這樣會導致雙層轉義。遇到這種情況時可以使用函數 get_magic_quotes_gpc() 進行檢測。
<?php
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()。
?>