当前位置:编程学习 > php >>

对于PHP初学者来说有什么方法可以知道页面需要哪个函数吗

对于PHP初学者来说,有什么方法可以知道页面需要哪个PHP函数吗

 

有没有简单的方法呢? 

例如下面这个例子。。。用到了哪些PHP函数呢?

 

<?php
 if($_REQUEST["k"] !="" && is_numeric($_REQUEST["k"]) ==true){
      include_once './func/inc.php';
      if(strlen(trim($_REQUEST["k"]))!=7 && strlen(trim($_REQUEST["k"]))!=11){
      echo "请输入输入手机号码前7位或11位";
      }else{
           $mobile=GetMobilePhone(trim($_REQUEST["k"]));
           if($mobile=="Wrong")echo "暂时无法调用数据,请稍侯查询!";
           elseif($mobile=="Wrong data")echo "您输入的手机号码有误,请重新输入!";
           else{
                  $strs="<table cellspacing=\"1\" width=400 id=\"alexa\"><tbody>\r\n";
                  $strs.="<tr><td width=100>手机号码:</td><td>{$mobile['Mobile']}</td></tr>";
                  $strs.="<tr><td>所属省份:</td><td>{$mobile['Province']}</td></tr>";
                  $strs.="<tr><td>所属城市:</td><td>{$mobile['City']}</td></tr>";
                  $strs.="<tr><td>区  号:</td><td>{$mobile['AreaCode']}</td></tr>";
                  $strs.="<tr><td>邮  编:</td><td>{$mobile['PostCode']}</td></tr>";
                  $strs.="<tr><td>类  型:</td><td>{$mobile['Corp']}{$mobile['Card']}</td></tr>";
                  $strs.="</tbody></table>";
                  echo $strs;
     }
      }
 }elseif($_REQUEST["k"] ==""){
 }else{
       echo "请输入输入手机号码前7位或11位";
 }
?>

 

 

 


<?php
function GetMobilePhone($phoneid=""){
    if(!is_numeric($phoneid))return false;
$json=@file_get_contents(" http://api.sj.com/locakting/?m={$phoneid}&output=json");
 $mobile=json_decode($json,true);
 if(!$mobile)return "Wrong";
 else{
        if(!$mobile['QueryResult'] || $mobile['QueryResult']=="False")return "Wrong data";
     $mobile['QueryResult']=iconv("UTF-8","GB2312//IGNORE",$mobile['QueryResult']);
     $mobile['Province']=iconv("UTF-8","GB2312//IGNORE",$mobile['Province']);
     $mobile['City']=iconv("UTF-8","GB2312//IGNORE",$mobile['City']);
     $mobile['Corp']=iconv("UTF-8","GB2312//IGNORE",$mobile['Corp']);
     return $mobile;
 }
}
?>

 

答案:
其实也没有用什么函数,都是基础的东西,看不懂就查一下php手册和百度,看多就懂了,例子用了计算长度strlen,清空trim,iconv转码,is_numeric判断是否数字,file_get_contents采取内容,json_decode编译,不懂查一下php手册吧

上一个:PHP怎么简单抓取与显示,要用到什么函数吗?
下一个:php中,金额转换的函数是什么啊!

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,