php通用檢測函數集(3)_PHP教程

來源:互聯網
上載者:User
// 函數名:CheckTelephone($C_telephone)
// 作 用:判斷是否為合法電話號碼
// 參 數:$C_telephone(待檢測的電話號碼)
// 傳回值:布爾值
// 備 註:無
//-----------------------------------------------------------------------------------
-------
function CheckTelephone($C_telephone)
{
if (!ereg("^[+]?[0-9]+([xX-][0-9]+)*$", $C_telephone)) return false;
return true;
}
//-----------------------------------------------------------------------------------
-------


//-----------------------------------------------------------------------------------
-------
// 函數名:CheckValueBetween($N_var, $N_val1, $N_val2)
// 作 用:判斷是否是某一範圍內的合法值
// 參 數:$N_var 待檢測的值
// $N_var1 待檢測值的上限
// $N_var2 待檢測值的下限
// 傳回值:布爾值
// 備 註:無
//-----------------------------------------------------------------------------------
-------
function CheckValueBetween($N_var, $N_val1, $N_val2)
{
if ($N_var < $N_var1 ││ $N_var > $N_var2)
{
return false;
}
return true;

}
//-----------------------------------------------------------------------------------
-------


//-----------------------------------------------------------------------------------
-------
// 函數名:CheckPost($C_post)
// 作 用:判斷是否為合法郵編(固定長度)
// 參 數:$C_post(待check的郵遞區號)
// 傳回值:布爾值
// 備 註:無
//-----------------------------------------------------------------------------------
-------
function CheckPost($C_post)
{
$C_post=trim($C_post);
if (strlen($C_post) == 6)
{
if(!ereg("^[+]?[_0-9]*$",$C_post))
{
return true;;
}else
{
return false;
}
}else
{
return false;;
}
}
//-----------------------------------------------------------------------------------
-------


//-----------------------------------------------------------------------------------
-------

http://www.bkjia.com/PHPjc/532630.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532630.htmlTechArticle// 函數名:CheckTelephone($C_telephone) // 作 用:判斷是否為合法電話號碼 // 參 數:$C_telephone(待檢測的電話號碼) // 傳回值:布爾值 // 備 註:...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.