<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ## curl發送post請求 ``` function sendCurl($url, $data = [], $curlOption = []) { $curl = curl_init(); // 啟動一個CURL會話 curl_setopt($curl, CURLOPT_URL, $url); // 要訪問的地址 if(!empty($data)){ curl_setopt($curl, CURLOPT_POST, 1); // 發送一個常規的Post請求 curl_setopt($curl, CURLOPT_POSTFIELDS, is_array($data) ? http_build_query($data) : $data); // Post提交的數據包 } curl_setopt($curl, CURLOPT_HEADER, false); // 顯示返回的Header區域內容 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 獲取的信息以文件流的形式返回 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 對認證證書來源的檢查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); // 從證書中檢查SSL加密算法是否存在 if(!empty($curlOption)){ foreach ($curlOption as $option => $value){ curl_setopt($curl, $option, $value); } } curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模擬用戶使用的瀏覽器 curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自動跳轉 curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自動設置Referer curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 設置超時限制防止死循環 $result = curl_exec($curl); // 執行操作 // print_r(curl_error($curl)); curl_close($curl); // 關閉CURL會話 return $result; } ``` ## 返回成功或者失敗 ``` /** * @author ty * @param string $msg * @param array $data * @desc 返回成功信息 */ public static function returnSuccess($msg = '', $data = []) { $data = [ 'code' => 1, 'msg' => $msg, 'data' => $data ]; echo json_encode($data, JSON_UNESCAPED_UNICODE); exit; } /** * @param string $msg * @param array $data * @desc 返回失敗信息 */ public static function returnErr($msg = '', $data = []) { $data = [ 'code' => -1, 'msg' => $msg, 'data' => $data ]; echo json_encode($data, JSON_UNESCAPED_UNICODE); exit; } ``` ## 修改字符串編碼 ``` /** * Convert encoding. * * @param string $string * @param string $fromEncoding * @param string $toEncoding * @static * @access public * @return string */ static public function convertEncoding($string, $fromEncoding, $toEncoding = 'utf-8') { $toEncoding = str_replace('utf8', 'utf-8', $toEncoding); if(function_exists('mb_convert_encoding')) { /* Remove like utf-8//TRANSLIT. */ $position = strpos($toEncoding, '//'); if($position !== false) $toEncoding = substr($toEncoding, 0, $position); /* Check string encoding. */ $encoding = strtolower(mb_detect_encoding($string, array('ASCII','UTF-8','GB2312','GBK','BIG5'))); if($encoding == $toEncoding) return $string; return mb_convert_encoding($string, $toEncoding, $encoding); } elseif(function_exists('iconv')) { if($fromEncoding == $toEncoding) return $string; $convertString = @iconv($fromEncoding, $toEncoding, $string); /* iconv error then return original. */ if(!$convertString) return $string; return $convertString; } return $string; } ``` ## 校驗身份證是否合法 ``` //檢測身份證是否合法以及是否正確 function cardCheck($cardId) { //$cardId="430181198707051478"; //判斷是否為18位 if(strlen($cardId) != 18) { return false; } //取最后一位 該位為校驗碼 $lastc = substr($cardId,17,1); //加權因子 $wi = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2']; //校驗碼對照表 $checkV = ['1', '0', 'x', '9', '8', '7', '6', '5', '4', '3', '2']; $sum = 0; for( $i=0; $i<17; $i++){ //取第$i位于加權因子數組的第$i行 相乘 $n = substr($cardId,$i,1); $num = (int)$n*(int)$wi[$i]; $sum += $num; } //和sum除11取余就為該身份證的最后一位校驗碼 $m = $sum%11; if($checkV[$m] == strtolower($lastc)){ return true; } else{ return false; } } ``` ## 導出excel ``` header("Content-Type: application/vnd.ms-excel; name='excel'"); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=導出.xls"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Expires: 0"); exit($str); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看