160319

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php

   
   /*$a = "a/sd";
   $b = 'a\sd';
   echo $a."<br>";
   echo $b;*/
 /* function Name()
  {
    echo "asd";  
    }
  Name();*/
  
  /*function Test($a,$b)
  {
      return $a+$b;
      
      }
  echo Test(1,2);*/
  
  /*function Test($a=1,$b=2)
  {
      echo $a+$b;
      }
  echo Test(3,3);*/
  
  /*function Test()
  {
      $asd = func_get_args();
      
      for($a=0;$a<count($asd);$a++)
      {
          echo "第{$a}个参数是{$asd[$a]}";
          }
      }
  Test(1,2,10,"aa");*/
  
 /* function Test()
  {
      $asd = func_get_args();
      
      $sum = 0;
      for($a=0;$a<count($asd);$a++)
      {
          $sum = $sum+$asd[$a];
          }
          return $sum;
      }
  echo Test(1,2,10,"aa");*/
  
  //全局变量
/*  $a = 6;
  function Test()
  {
      global $a;//将变量作为一个全局变量
      $a = $a+10;
      echo $a,"<br>";
      }
      Test();
      echo $a;*/
      //字符串常用函数
      $a = "hello";
      //echo strlen($a);//输出字符串的长度
  $b = "Hello";
  //echo strcmp($a,$b);//判断两个字符串是否相同,相同返回0,区分大小写
    //echo strcasecmp($a,$b);//判断字符串是否相同,不区分大小写
  
   //echo strtolower($b);//转换成小写
   //echo strtoupper($a);//转换成大写
   
  /* $aa = "aaaa|ssss|dddd";
   $aa = explode("|",$aa);//拆分字符串,返回参数组
   print_r ($aa);
    
    echo implode("#",$aa);//讲数组拼成字符串*/
  
  /*$aa = "asafsfasdasd";
  echo substr_replace($aa,"pp",0,2);//替换指定位置的字符串
  
  echo str_replace("as","dd",$aa);//查找替换
  echo substr($aa,0,5);//截取字符串
*/
   
   //其它常用参数
  // echo rand(1,100);//随机数生成,可写范围
   //echo time();//但会当前日期时间的时间戳
   //echo date("Y-m-d H:i:s:ms");

   //正则表达式
   $reg = "/(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}/";
   $str = "vv18653378660v18653378665v2h0hh";
   //echo preg_replace($reg,"#",$str)//替换字符串
    
    //print_r(preg_split($reg,$str));//拆分字符串
    
    $arr= array();
    preg_match_all($reg,$str,$arr);//匹配所有
    print_r($arr);



?>

</body>
</html>

 

posted @ 2016-03-19 23:35  呼哧呼哧  阅读(244)  评论(0编辑  收藏  举报