乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      php語(yǔ)法

       何勇力 2010-09-25
      1、聲明全局變量,在函數(shù)中使用,使用前要先聲明glebal然后再使用或者用$GLOBALS["全局變量名"]
      2、如果從一個(gè)頁(yè)面調(diào)用另一個(gè)頁(yè)面的函數(shù),用include()或者用require()函數(shù)。為了避免重復(fù)包含通??捎煤瘮?shù)include_once()或者用require_once().
      3、printf函數(shù)按照格式輸出數(shù)據(jù)。例如:$num=100.001; printf("%s----%d-----%b----%x---%o",$num,$num,$num,$num,$num);是分別按照字符串----整數(shù)----二進(jìn)制----十六進(jìn)制----八進(jìn)制輸出。------>%c表示阿斯特馬值;%.1f表示小數(shù)點(diǎn)后保留幾位小數(shù),改變1,2,3....
      4、ltrim():去掉字符串左空格;
         rtrim():去掉字符串右空格;
         trim() :去掉字符串兩邊空格;
         strrev():將字符串前后顛倒;
         strlen():獲取字符串的長(zhǎng)度;
         strtolower():將為小寫(xiě);
         strtoupper():轉(zhuǎn)為大寫(xiě);
         ucfirst(): 將字符串中第一個(gè)字符改為大寫(xiě);
         ucwords():將字符串中每個(gè)單詞第一個(gè)字符改為大寫(xiě);
         explode(string separator,string str<要分割的字符串>,[,int limit]<數(shù)組的長(zhǎng)度>): 使用一個(gè)字符串分割另一個(gè)字符串;
         implode(string glue<要聯(lián)合的字符串>,array pieces<數(shù)組>):用一組較小的字符串創(chuàng)建一個(gè)大字符串;
         join():和implode函數(shù)一樣,使用方法一樣;
         substr(string string,int start[,int length]):取部分字符串;
         strstr(string ,string)別名strchr();返回字符串中某字符串開(kāi)始處至結(jié)束處的字符串;
         strpos(string,char,[,int offset]):尋找字符中某字符最先出現(xiàn)的位置;
         strrchr(string,char):查詢最后一個(gè)字符到結(jié)尾的字符串;
         str_pad(string str<指明要處理的字符串>,int length<給定處理后字符串的長(zhǎng)度>,string add<要填補(bǔ)的字符串>,__________<填補(bǔ)的方向>):字符串的填補(bǔ)函數(shù) STR_PAD_LEFT STR_PAD_RIGHT STR_PAD_BOTH
      5、字符串比較
         ①:按字節(jié)進(jìn)行字符串比較;
       /*//strcmp()按字節(jié)進(jìn)行字符串比較---->strcasecmp()區(qū)別就是不分大小寫(xiě)
       $str1="hello";
       $str2="hello";
       if(strcmp($str1,$str2)==0)
       {
        echo $str1."等于".$str2;
       }else{
        echo $str1."不等于".$str2;
       }*/
         ②:按自然數(shù)排序法比較字符串;
       /*//按自然數(shù)比較字符串strnatcmp()。輸出photo12.jpg
       $arr=array("photo1.jpg","photo2.jgp","photo10.jpg","photo12.jpg");
       $max_str=$arr[0];
       for($i=1;$i<count($arr);$i++)
       {
       
        if(strnatcmp($arr[$i],$max_str)>0)
        {
         $max_str=$arr[$i];
        }
       }
       echo $max_str;*/
        ③:字符串的模糊比較
       /*//字符串的模糊比較soundex()比較發(fā)音
       $str1="sun";
       $str2="son";
       echo soundex($str1);
       echo "<br>";
       echo soundex($str2);
       if (soundex($str1)==soundex($str2))
       {
        echo "<br>相等";
       }else{
        echo "<br>不相等";
       }*/
        ④:字符串的模糊比較
       /*//字符串的模糊比較similar_text(string str1,string str2 [,一個(gè)變量])。如果是兩個(gè)參數(shù),
       //比較相對(duì)應(yīng)的個(gè)數(shù);如果有第三個(gè)參數(shù),代表的是相匹配的百分比.輸出結(jié)果:6;60%
       $str1="helloabbcd";
       $str2="hellsdddcd";
       echo similar_text($str1,$str2,$similar);
       echo "<br>";
       echo $similar."%";*/
         ⑤:替換字符串
            1>/*//替換字符串str_replace(string a,string b,string c)意思是在c里找到字符串a(chǎn),替換成b
       $str="http://www.";
       $url=str_replace("rongankeji","dp",$str);
       echo $str."<br>";    //輸出http://www.
       echo $url;    //輸出http://www.*/
            2>/*//②替換字符串的另一種形式str_replace(array a, string b,string c)意思是將c里是反有數(shù)組里數(shù)據(jù)的都換成b
       $str=" echo $str."<br>";  //輸出http://www.baidu.com
       echo $url;   //輸出:lmap://www.lmap.lmap*/
           3>/*//③替換字符串的另一種形式str_replace(array a, array b,string c)意思是將c里是反有數(shù)組a里數(shù)據(jù)的都換成數(shù)組b( //a和b必須一一相應(yīng))
       $str=" $url=str_replace($arr,$arr1,$str);
       echo $str."<br>";  //輸出
      http://www.baidu.com
       echo $url;    //輸出:ftp://www.google.cn*/
      6、    ①:/*//翻譯函數(shù)strtr(string a,string b,string c)將a里的所有b里面的元素?fù)Q成c里面 的元素
       $str=" echo $str."<br>";  //輸出http://www.tom.com/bbs/content.php
       echo $url;    //輸出http://www./bbs/nentent.php*/
             ②:/*//翻譯函數(shù)strtr(string a,array b)將a里的
       $str=" $url=strtr($str,$arr);
       echo $str."<br>";  //輸出
      http://www.tom.com/bbs/content.php
       echo $url;    //輸出ftp://www./bbs/content.jsp*/
      7、//stripslashes():去點(diǎn)轉(zhuǎn)義符號(hào)例如
       echo $_GET["username"]."<br>";   //輸出結(jié)果是this is a \"demo\"   ;
       echo stripslashes($_GET["username"]);//輸出結(jié)果是this is a "demo"  ;
         //將html標(biāo)簽實(shí)體化htmlentities();
       echo htmlentities($_GET["username"]);
         //兩個(gè)函數(shù)一起使用
       echo htmlentities(stripslashes($_GET["username"]));
        //刪除標(biāo)簽只顯示實(shí)體strip_tags()
       echo strip_tags(stripslashes($_GET["username"]));//輸出結(jié)果沒(méi)有標(biāo)簽

      8、 /*current(數(shù)組的名稱)key(數(shù)組的名稱)取的是數(shù)組里第一個(gè)值
        *
        * next(數(shù)組名稱),prev()-->上一條語(yǔ)句,end(),reset()
        *
        * count(),sizeof()求數(shù)組的長(zhǎng)度
        *
        * array_change_key_case(目標(biāo)數(shù)組,動(dòng)態(tài)常數(shù))-->改變下標(biāo)索引
        *   CASE_UPPER<轉(zhuǎn)變成大寫(xiě)>   CASE_LOWER<轉(zhuǎn)變成小寫(xiě)>
        * array_chunk(目標(biāo)數(shù)組,索引個(gè)數(shù),[boolean])
        *   ①:傳要更改的數(shù)組;   ② 表示分的數(shù)組里的個(gè)數(shù);③是否保留原有的所有
        *
        * array_count_values(數(shù)組名稱)-->計(jì)算數(shù)組中各值出現(xiàn)的次數(shù)。返回的新數(shù)組里值為索引,出現(xiàn)的個(gè)數(shù)為值
        *
        * array_fill(起始索引位置,區(qū)段大小,指定字元);
        *
        * array_filter(目標(biāo)數(shù)組,使用者定義的函數(shù));過(guò)濾函數(shù)
        *
        * array_walk();
        *
        * array_map();
        *
        * array_flip(目標(biāo)數(shù)組);-->將鍵和值對(duì)掉
        *
        * array_sum(目標(biāo)數(shù)組);-->所有目標(biāo)函數(shù)值的總和
        *
        * array_unique();
        */
       
       /*//遍歷數(shù)組的幾個(gè)方法
       $arr=array("hello"=>"one","two","three",1,2,3,5,8,"four");
       echo key($arr)."==>".current($arr);//輸出hello==>one
       echo "<br>";
       next($arr);//下一條語(yǔ)句
       echo key($arr)."==>".current($arr);//輸出0==>two
       echo "<br>";
       next($arr);//下一條語(yǔ)句
       echo key($arr)."==>".current($arr);//輸出1==>three
       echo "<br>";
       end($arr);//執(zhí)行數(shù)組最后一條語(yǔ)句
       echo key($arr)."==>".current($arr);//輸出7==>four
       echo "<br>";
       reset($arr);//將指針變?yōu)闊o(wú)條件狀態(tài),執(zhí)行第一條
       echo key($arr)."==>".current($arr);//輸出hello==>one
       echo "<br>";*/

       /*//數(shù)組的長(zhǎng)度
       $arr=array("hello"=>"one","two","three",1,2,3,5,8,"four");
       echo count($arr)."<br>";
       echo sizeof($arr);*/

       /*//改變索引的大小寫(xiě)
       $arr=array("ONE"=>"one","Hello"=>"two","Xxs"=>"three","abc","www"=>"123",1,3,5,9);
       $newarr=array_change_key_case($arr,CASE_UPPER);
       print_r($newarr); //輸出Array ( [ONE] => one [HELLO] => two [XXS] => three [0] => abc [WWW] => 123 [1] => 1   [2] => 3 [3] => 5 [4] => 9 )
       */
       /*//數(shù)組被拆分第一個(gè)參數(shù)傳數(shù)組,第二個(gè)參數(shù)代表被分的數(shù)組有幾個(gè)值
       $arr=array("ONE"=>"one","Hello"=>"two","Xxs"=>"three","abc","www"=>"123",1,3,5,9);
       $newarr=array_chunk($arr,4,true);
       print_r($newarr);*/
       /*//array_count_values(目標(biāo)數(shù)組),返回的新數(shù)組里值為索引,出現(xiàn)的個(gè)數(shù)為值
       $arr=array("hello"=>"one","www"=>"two","xxx"=>"three",1,2,2,1,1,1,12,2,"one","one","two","two",4,3,5,3);
       $newarr=array_count_values($arr);
       print_r($newarr);*/
       /*//創(chuàng)建數(shù)組array_fill
       $arr=array_fill(10,100,"uselib");
       print_r($arr);*/
       /*//過(guò)濾函數(shù)array_filter(目標(biāo)數(shù)組,函數(shù));
       function fun1($value)
       {
        if ($value==0) {
         return true;
        }else{
         return false;
        }
       }
       $arr=array("ONE"=>"one","Hello"=>"two","Xxs"=>"three","abc","www"=>"123",1,3,5,9);
       $newarr=array_filter($arr,fun1);
       print_r($newarr);*/
       /*//函數(shù)array_map(函數(shù),目標(biāo)數(shù)組);
       function fun1($value){
        return $value*$value;
       }
       $arr=array(1,2,3,-7,-1,-9);
       $newarr=array_map(fun1,$arr);
       print_r($newarr);*/
       /*//函數(shù)array_flip(目標(biāo)數(shù)組)-->鍵和值對(duì)掉形成新數(shù)組
       $arr=array("ONE"=>"one","Hello"=>"two","Xxs"=>"three","abc","www"=>"123",1,-3,-5,9);
       $newarr=array_flip($arr);
       print_r($newarr);*/
       /*//函數(shù)array_sum(目標(biāo)函數(shù))-->所有值的和
       $arr=array(1,4,2,1,-1,-9,-34,12,-56,122);
       $newarr=array_sum($arr);
       echo $newarr;*/
       /*//函數(shù)array_unique();取數(shù)組中唯一的
       $arr=array(1,1,1,1,1,2,2,2,2,2,5,0,5,3,2,6,7,8,9);
       $newarr=array_unique($arr);
       print_r($newarr);*/
      9、 重寫(xiě)父類方法:
       parent::父類中的方法;然后在加上自己添加的語(yǔ)句;
       父類的方法修飾符必須低于子類的方法修飾符。
      10、final
       使用final定義的類不能被繼承。
       使用final定義的方法不能被重載
      11、static成員,使用類名::$成員 this self
               修飾屬性,也可以修飾方法用static聲明方法里面不能使用非靜態(tài)成員。
      12、const 是一個(gè)在類里面定義成員屬性為常量的關(guān)鍵字
          類名::成員屬性
          只能修飾屬性,只有在聲明的時(shí)候給初始值
      13、__toString()__clone()__call()__autoload()
       

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多