久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php高級(jí)函數(shù)有哪些

      php高級(jí)函數(shù)有哪些

      PHP高級(jí)函數(shù)

      1、call_user_func

      // 官網(wǎng)地址: http://php.net/manual/zh/function.call-user-func.php

      2、get_class

      // 官網(wǎng)地址: http://php.net/manual/zh/function.get-class.php

      3、get_called_class

      // 官網(wǎng)地址: http://php.net/manual/zh/function.get-called-class.php

      4、array_map

      // 官網(wǎng)地址:http://php.net/manual/zh/function.array-map.php //為數(shù)組的每個(gè)元素應(yīng)用回調(diào)函數(shù) 示例: $str = '1 ,2,3'; $res = array_map(function ($v) {     return intval(trim($v)) * 2; }, explode(',', $str)); $res的返回結(jié)果: array(3) { [0]=> int(2) [1]=> int(4) [2]=> int(6) }

      5、strpos

       // http://php.net/manual/zh/function.strpos.php //查找字符串首次出現(xiàn)的位置,從0開始編碼,沒有找到返回false 示例: $time = "2019-03-02 12:00:00"; if(strpos($time,':') !== false){     $time = strtotime($time); } echo $time;

      6、array_reverse

      // 官網(wǎng)地址:http://php.net/manual/zh/function.array-reverse.php //返回單元順序相反的數(shù)組 示例: $time = "12:13:14"; $arrTime = array_reverse(explode(':',$time)); var_dump($arrTime); array(3) { [0]=> string(2) "14" [1]=> string(2) "13" [2]=> string(2) "12" }

      7、pow

      // 官網(wǎng)地址:http://php.net/manual/zh/function.pow.php //指數(shù)表達(dá)式 示例: $time = "12:13:14"; $arrTime = array_reverse(explode(':',$time)); $i = $s = 0; foreach($arrTime as $time){     $s += $time * pow(60,$i);  // 60 的 $i 次方     $i ++; } var_dump($s); int(43994)

      8、property_exist

      // 官網(wǎng)地址:http://php.net/manual/zh/function.property-exists.php // 檢查對(duì)象或類是否具有該屬性 //如果該屬性存在則返回 TRUE,如果不存在則返回 FALSE,出錯(cuò)返回 NULL 示例: class Test {     public $name = 'daicr';     public function index()     {         var_dump(property_exists($this,'name')); // true     } }

      9、passthru

      // 官網(wǎng)地址:http://php.net/manual/zh/function.passthru.php //執(zhí)行外部程序并且顯示原始輸出 //功能和exec() system() 有類似之處 示例: passthru(Yii::$app->basePath.DIRECTORY_SEPARATOR . 'yii test/index');

      10、array_filter

      // 官網(wǎng)地址:http://php.net/manual/zh/function.array-filter.php //用回調(diào)函數(shù)過濾數(shù)組中的單元 示例: class TestController extends yiiconsoleController {     public $modules = '';     public function actionIndex()     {         //當(dāng)不使用callBack函數(shù)時(shí),array_filter會(huì)去除空值或者false         $enableModules = array_filter(explode(',',$this->modules));         var_dump(empty($enableModules)); //true         //當(dāng)使用callBack函數(shù)時(shí),就會(huì)用callBack過濾數(shù)組中的單元         $arr = [1,2,3,4];         $res = array_filter($arr,function($v){            return $v & 1;  //先轉(zhuǎn)換為二進(jìn)制,在按位進(jìn)行與運(yùn)算,得到奇數(shù)         });         var_dump($res);         //array(2) { [0]=> int(1) [2]=> int(3) }     } }

      11、current

      // 官網(wǎng)地址:http://php.net/manual/zh/function.current.php //返回?cái)?shù)組中的當(dāng)前單元 $arr = ['car'=>'BMW','bicycle','airplane']; $str1 = current($arr); //初始指向插入到數(shù)組中的第一個(gè)單元。 $str2 = next($arr);    //將數(shù)組中的內(nèi)部指針向前移動(dòng)一位 $str3 = current($arr); //指針指向它“當(dāng)前的”單元 $str4 = prev($arr);    //將數(shù)組的內(nèi)部指針倒回一位 $str5 = end($arr);     //將數(shù)組的內(nèi)部指針指向最后一個(gè)單元 reset($arr);           //將數(shù)組的內(nèi)部指針指向第一個(gè)單元 $str6 = current($arr); $key1 = key($arr);     //從關(guān)聯(lián)數(shù)組中取得鍵名 echo $str1 . PHP_EOL; //BMW echo $str2 . PHP_EOL; //bicycle echo $str3 . PHP_EOL; //bicycle echo $str4 . PHP_EOL; //BMW echo $str5 . PHP_EOL; //airplane echo $str6 . PHP_EOL; //BMW echo $key1 . PHP_EOL; //car var_dump($arr);   //原數(shù)組不變

      12、array_slice

      // 官網(wǎng)地址:http://php.net/manual/zh/function.array-slice.php //從數(shù)組中取出一段 示例: $idSet = [1,2,3,4,5,6,7,8,9,10]; $total = count($idSet); $offset = 0; $success = 0; while ($offset < $total){     $arrId = array_slice($idSet,$offset,5);     //yii2的語法,此處,注意array_slice的用法就行     $success += $db->createCommand()->update($table,['sync_complate'=>1],['id'=>$arrId])->execute();      $offset += 50; } $this->stdout('共:' . $total . ' 條,成功:' . $success . ' 條' . PHP_EOL,Console::FG_GREEN); //yii2的語法

      13、mb_strlen()

      // 官網(wǎng)地址:http://php.net/manual/zh/function.mb-strlen.php //獲取字符串的長度 //strlen 獲取的是英文字節(jié)的字符長度,而mb_stren可以按編碼獲取中文字符的長度 示例: $str1 = 'daishu'; $str2 = '袋鼠'; echo strlen($str1) . PHP_EOL;                //6 echo mb_strlen($str1,'utf-8') . PHP_EOL;  //6 echo strlen($str2) . PHP_EOL;               // 4 一個(gè)中文占 2 個(gè)字節(jié) echo mb_strlen($str2,'utf-8') . PHP_EOL;  //2 echo mb_strlen($str2,'gb2312') . PHP_EOL; //2

      14、list

      // 官網(wǎng)地址:http://php.net/manual/zh/function.list.php //把數(shù)組中的值賦給一組變量 示例: list($access,$department)= ['all','1,2,3']; var_dump($access); // all

      15、strcasecmp

      // 官網(wǎng)地址:https://www.php.net/manual/zh/function.strcasecmp.php //二進(jìn)制安全比較字符串(不區(qū)分大小寫) //如果 str1 小于 str2 返回 < 0; 如果 str1 大于 str2 返回 > 0;如果兩者相等,返回 0。 示例: $str1 = 'chrdai'; $str2 = 'chrdai'; var_dump(strcasecmp($str1,$str2)); // int 0

      16、fopen rb

      // 官網(wǎng)地址:https://www.php.net/manual/zh/function.fopen.php //1、使用 'b' 來強(qiáng)制使用二進(jìn)制模式,這樣就不會(huì)轉(zhuǎn)換數(shù)據(jù),規(guī)避了widown和unix換行符不通導(dǎo)致的問題, //2、還有就是在操作二進(jìn)制文件時(shí)如果沒有指定'b'標(biāo)記,可能會(huì)碰到一些奇怪的問題,包括壞掉的圖片文件以及關(guān)于rn 字符的奇怪問題。 示例: $handle = fopen($filePath, 'rb');

      17、fseek

      // 官網(wǎng)地址:https://www.php.net/manual/zh/function.fseek.php //在文件指針中定位 //必須是在一個(gè)已經(jīng)打開的文件流里面,指針位置為:第三個(gè)參數(shù) + 第二個(gè)參數(shù) 示例: //將文件指針移動(dòng)到文件末尾 SEEK_END + 0 fseek($handle, 0, SEEK_END);

      18、ftell

      // 官網(wǎng)地址:https://www.php.net/manual/zh/function.ftell.php //返回文件指針讀/寫的位置 //如果將文件的指針用fseek移動(dòng)到文件末尾,在用ftell讀取指針位置,則指針位置即為文件大小。 示例: //將文件指針移動(dòng)到文件末尾 SEEK_END + 0 fseek($handle, 0, SEEK_END); //此時(shí)文件大小就等于指針的偏移量 $fileSize = ftell($handle);

      19、basename

      // 官網(wǎng)地址:https://www.php.net/manual/zh/function.basename.php //返回路徑中的文件名部分 示例: echo basename('/etc/sudoers.d');   // sudoers ,注意沒有文件的后綴名,和pathinfo($filePath)['filename']功能差不多

      20、pathinfo

      // 官網(wǎng)地址:https://www.php.net/manual/zh/function.pathinfo.php //返回文件路徑的信息 示例: $pathParts = pathinfo('/etc/php.ini'); echo $pathParts['dirname'] . PHP_EOL;     // /etc ,返回路徑信息中的目錄部分 echo $pathParts['basename'] . PHP_EOL;  // php.ini ,包括文件名和拓展名 echo $pathParts['extension'] . PHP_EOL; // ini ,拓展名 echo $pathParts['filename'] . PHP_EOL;  // php ,只有文件名,不包含拓展名 ,和basename()函數(shù)功能差不多

      21、headers_sent($file, $line)

      // 官網(wǎng)地址:https://www.php.net/manual/zh/function.headers-sent.php //檢測 HTTP 頭是否已經(jīng)發(fā)送 //1、http頭已經(jīng)發(fā)送時(shí),就無法通過header()函數(shù)添加

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)