[PHP]实用函数3

2019-04-11 00:08:13王振洲
//获得当前的脚本网址

function get_php_url(){ 
        if(!empty($_server["REQUEST_URI"])){ 
                $scriptName = $_SERVER["REQUEST_URI"]; 
                $nowurl = $scriptName; 
        }else{ 
                $scriptName = $_SERVER["PHP_SELF"]; 
                if(empty($_SERVER["QUERY_STRING"])) $nowurl = $scriptName; 
                else $nowurl = $scriptName."?".$_SERVER["QUERY_STRING"]; 
        } 
        return $nowurl; 


//把全角数字转为半角数字

function GetAlabNum($fnum){ 
        $nums = array("0","1","2","3","4","5","6","7","8","9"); 
        $fnums = "0123456789"; 
        for($i=0;$i<=9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum); 
        $fnum = ereg_replace("[^0-9.]|^0{1,}","",$fnum); 
        if($fnum=="") $fnum=0; 
        return $fnum; 


//去除HTML标记

function Text2Html($txt){ 
        $txt = str_replace("  "," ",$txt); 
        $txt = str_replace("<","<",$txt); 
        $txt = str_replace(">",">",$txt); 
        $txt = preg_replace("/[rn]{1,}/isU"," 
rn",$txt); 
        return $txt; 


//清除HTML标记 


function ClearHtml($str){ 
        $str = str_replace('<','<',$str); 
        $str = str_replace('>','>',$str); 
        return $str; 


//相对路径转化成绝对路径
相关文章 大家在看