php常用技巧小計

1.
htmlspecialchars("<script>alert('sdfsdf');</script>");將腳本語言轉換爲html代碼,防止腳本運行。
2. 該函數是將文本中回車變爲<br>將空格變爲&nbsp;
function htmtocode($content){
$content=str_replace("/n","<br>",str_replace(" ","&nbsp;",$content));
return $content;
}
3.獲取IP地址
$ip = gethostbyname('www.baidu.com');
$iipp=

tiny_mce_marker

SERVER["REMOTE_ADDR"];
4.常用類中函數
function __autoload($class_n){
//自動載入進當前頁面
include($class_n.".php");
}

function __tostring(){
return "這是個什麼樣的類";
}
function __call($function,$array_v)
{
echo "不存在方法爲:".$function."<br>";
echo "錯誤的值:".print_r($array_v);
}
function __clone(){
echo "nidelei";
}
function __destruct(){
echo "清理一個對象";
}
5.......

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章