Time of Update: 2016-07-25
/** php 檢測遠端檔案是否存在 by http://bbs.it-home.org*/function get_http_response_code($theURL) { $headers = get_headers($theURL); return substr($headers[0], 9, 3); } /** * Fetches all the real headers sent by the server in response to a HTTP
Time of Update: 2016-07-25
學東西容易。化為己有難。新手程式員發現自己在最近的幾個項目中偷竊了其它項目的思想。當然,並不是真正的“偷”,而是瀏覽和學習你欣賞的項目和開發人員,從中竊取思想。諸如設計模式,重構方法等。Chris是如何處理hub裡的命令列參數的?shell指令碼和rvm上的Ruby是如何進行韋恩轉化的?當你遇到問題,有點難度、需要你動一下腦子時,你要問“嗨,我怎麼實現這個呢?”,這是個不錯的問題入手點。
Time of Update: 2016-07-25
var_dump(is_file('a_file.txt')) . "\n";var_dump(is_file('/usr/bin/')) . "\n";?> 複製代碼輸出:bool(true)bool(false)例2: function isfile($file){return preg_match('/^[^.^:^?^-][^:^?]*.(?i)' . getexts() . '$/',$file);//first character cannot be . : ? -
Time of Update: 2016-07-25
//取檔案的副檔名//by http://bbs.it-home.org$file = "/home/jbxue/file_20130322.txt";for($i=1; $i $func = 'get_file_ext_' . $i;var_dump($func($file));}function get_file_ext_1($file) {return strtolower(trim(substr(strrchr($file, '.'), 1)));}function
Time of Update: 2016-07-25
$url = 'http://xxxx.com'; $hander_array = get_headers ( $url ); if ($header_array [0] == 'HTTP/1.1 200 OK') { echo '檔案存在'; } else { echo '檔案不存在'; } 複製代碼說明:get_headers
Time of Update: 2016-07-25
這個比 scandir出來的好用 /** * 遍曆擷取目錄下的指定類型的檔案 * @param $path * @param array $files * @return array */ function getfiles( $path , &$files = array() ) { if ( !
Time of Update: 2016-07-25
為大家介紹一下php中的三個檔案或目錄判斷函數:file_exists、is_dir、is_file的區別,有興趣的朋友,可以瞭解下。有人這樣說,PHP的 file_exists = is_dir + is_file,呵呵,為什麼這樣說類?file_exists函數既可以判斷檔案是否存在,又可以判斷目錄是否存在。不過它的執行效率非常低,就像asp中request不指定是form,還是get,cookies,所以,聰明的你,一定可以順暢理解下面的總結:1、如果要判斷目錄是否存在,請用獨立函數
Time of Update: 2016-07-25
/*$array_name:傳入的數組;$row_id:數組想排序的項;$order_type:排序的方式,ASC或者DESC;*/ function array_sort($array_name,$row_id,$order_type){ $array_temp=array(); foreach($array_name as $key=>$value){//迴圈一層;
Time of Update: 2016-07-25
php過濾$_GET 和$_POST參數,以防止注入的代碼,有需要的朋友,可以參考下。完整代碼如下。$value){if(!is_array($value)){$value = get_magic_quotes_gpc()?$value:addslashes($value);$array[$key]=filterHtml($value);}Else{Add_S($array[$key]);}}return $array;}function glstr($var) {if
Time of Update: 2016-07-25
/** * 產生頁碼列表 * * @param int $element_total_count 元素總數 * @param int $current_page 當前頁 * @param int $per_page_elem_count 每頁元素數 * @param int $show_page_num 列表顯示的頁碼數 * @param string $up_down_class 上下翻頁樣式 * @param string $num_class 當前頁頁碼數字樣式 * @param
Time of Update: 2016-07-25
Class PAGE {//類開始 /********************************************************* $total 記錄總數* $pageNum 每頁顯示的條數* $url = '' 連結* $page->StartPage(顯示分類統計,字元分類/數字分頁,跳轉);* $page->StartPage(true/false, true/false, true/false);* site
Time of Update: 2016-07-25
$xp = new xf_HtmlDom(); $xp->loadHtml('http://dealer.bitauto.com/100040078/cars.html'); $rows = $xp->find('dl/dd/a', 0)->innertext; print_r($rows);
Time of Update: 2016-07-25
//擷取網卡MAC地址@exec("ipconfig/all",$array); for($Tmpa;$Tmpaif(eregi("Physical",$array[$Tmpa])){ $mac=explode(":",$array[$Tmpa]); echo $mac[1]; } }//擷取url主域//by http://bbs.it-home.orgfunction GetDomain($url){$pattern =
Time of Update: 2016-07-25
php 上傳檔案並產生縮圖的代碼,分為單檔案與多檔案上傳,並可以產生縮圖,確實不錯,建議大家參考學習下。完整代碼如下。* ******************************************************/function UpLoadFileAll($input='UpPic', $path='upload', $ftype='jpg,gif,png', $fsize=2){$fileInfo = $_FILES[$input];
Time of Update: 2016-07-25
php資料庫操作類,實現表的增刪改查,擷取行數,查詢多條資料記錄,左串連查詢,建立資料表結構等。功能豐富,方便移值,有需要的朋友,可以參考下。php資料庫類完整代碼與樣本如下。1、代碼links = mysql_connect(DB_HOST, DB_USER, DB_PWD);if(DEBUG){mysql_select_db(DB_NAME) or die('ERROR:'.mysql_error());}else{mysql_select_db(DB_NAME);}$char_sql =
Time of Update: 2016-07-25
一段php實現json增加積分的代碼,對於掌握如何在php中構造json資料很有協助,有需要的朋友,可以參考下。 代碼如下,僅供學習參考。 function zeng_integral(){ $jifen=& m('integral'); /*判斷網吧*/ $store=isset($store_id)?intval($store_id):0;
Time of Update: 2016-07-25
零一貸平台1月7日發標公告: 1、恒信豐擔保,深圳羅湖寫字樓抵押短借68萬元(綜合授信550萬,第三筆),年化18.5%,期限一個月,到期一次還本息,1月7日10:30發出 2、恒信豐擔保,廣東東莞房產抵押短借62萬元(綜合授信170萬,第二筆),年化18.5%,期限一個月,到期一次還本息,1月7日10:30發出 大家請上零一貸官網(www.loan01.com)查看 深圳廣業創富金融資訊服務有限公司 2015年1月7日
Time of Update: 2016-07-25
//create function with an exception function checkNum($number) { if($number>1) { throw new Exception("Value must be 1 or below"); } return true; } //trigger exception checkNum(2); ?>
Time of Update: 2016-07-25
為大家介紹一個php代碼實現的ftp操作類,實現檔案的上傳下載、複製移動、檔案的刪除、目錄的建立等,有需要的朋友,可以參考下。1、ftp類代碼conn_id = @ftp_connect($FTP_HOST,$FTP_PORT) or die("FTP伺服器串連失敗"); @ftp_login($this->conn_id,$FTP_USER,$FTP_PASS) or die("FTP伺服器登陸失敗"); @ftp_pasv($this->conn_id,1); /
Time of Update: 2016-07-25
$files = array('./test.jpg', 'test.png');$fileTypes = array(7790 => 'exe',7784 => 'midi',8075 => 'zip',8297 => 'rar',225216 => 'jpg',7173 => 'gif',6677 => 'bmp',13780 => 'png',);foreach($files as $file) {$fp = fopen($file, 'rb');