Time of Update: 2016-07-25
/*** 檢證檔案類型類** @author Silver* by bbs.it-home.org*/class FileTypeValidation{// 檔案類型,不同的頭資訊private static $_fileFormats = Array('jp2' => '0000000C6A502020', '3gp' => '0000002066747970','3gp5' => '0000001866747970','m4a' =>
Time of Update: 2016-07-25
php代碼擷取昨天與明天的日期,有需要的朋友,可以參考下。範例程式碼:"; echo "昨天:".date("Y-m-d",strtotime("-1 day")), ""; echo "明天:".date("Y-m-d",strtotime("+1 day")). ""; echo "一周后:".date("Y-m-d",strtotime("+1 week")). ""; echo "一周零兩天四小時兩秒後:".date("Y-m-d
Time of Update: 2016-07-25
為大家介紹phpmailer郵件類進行群發的例子,即同時指定多個收件者,是phpmailer應用的不錯的例子,有需要的朋友,可以參考下。PHPMailer群發郵件的例子,代碼如下:IsSMTP(); // send via SMTP $mail->Host = "smtp.163.com"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "test123"; //
Time of Update: 2016-07-25
本文介紹下,php中的mysql操作函數mysql_fetch_assoc()、mysql_fetch_array()、mysql_fetch_row()、mysql_fetch_object()在用法上的區別。供大家參考。相同點:三個函數都是返回資料庫中查詢到的一行資料(即一條資料)。不同點:mysql_fetch_assoc()用的是資料庫中相應的欄位名作為的key值(也就是數組下標)如:filed['id']=1;mysql_fetch_row()用的是自動產生的數字(從0開始依次產生)作
Time of Update: 2016-07-25
本文分析PHP+MySQL網站開啟速度慢的原因,有需要的朋友,可以參考下,加以改進,以提高網站訪問速度。1、資料庫表結構不合理在建立mysql資料庫表時,把經常作為查詢條件的欄位設定為索引,這樣可以提高資料的查詢速度,從而提高網站的開啟速度。2、資料庫查詢語句不合理PHP+MySQL**站,經常使用資料庫select操作。在使用select操作時,切忌不要輕易使用select * from
Time of Update: 2016-07-25
本文介紹下,有關php中實現多線程的一個類,有需要的朋友參考下。如何通過WEB伺服器實現PHP的多線程功能呢?在php編程中,通過WEB伺服器實現的多線程只能模仿多線程的一些效果,並不是真正意義上的多線程。在需要類似多線程的功能時,可以參考下下面的這個類。代碼:addthread('action_log','a'); * $thread->addthread('action_log','b'); * $thread->addthread('action_log','c'); *
Time of Update: 2016-07-25
本文介紹下,php中的eval函數的幾個例子,有需要的朋友參考下吧。在php中,eval函數用於將值代入字串之中。文法: void eval(string code_str); 傳回值: 無 函數種類: 資料處理 內容說明本函數可將字串之中的變數值代入,通常用在處理資料庫的資料上。參數 code_str 為欲處理的字串。注意:待處理的字串要符合 PHP 的字串格式,同時在結尾處要有分號。使用本函數處理後的字串會沿續到 PHP 程式結束。例子:'; echo $str; eval( "/$str
Time of Update: 2016-07-25
本文介紹下,php實現檔案下載時遇到的一些問題及解決方案,有需要的朋友參考下。在用php實現下載檔案時,彈出瀏覽器內建的下載框,出現另存新檔操作。有時會出現記憶體溢出和逾時的現象。逾時的話,可以設定set_time_limit(0);出現記憶體溢出的話,有可能是因為從資料庫中取出的資料量太大導致的。如果是從檔案中讀取的話,出現記憶體溢出的話,就是代碼讀取方式不正確,調用files或者filegetcontens才會。如果是fopen的話,就給一個緩衝區,固定大小,讀入然後寫入,不會出現記憶體溢出
Time of Update: 2016-07-25
Mac 在國外很受歡迎,尤其是在 設計/web開發/IT 人員圈子裡。普通使用者喜歡 Mac 可以理解,畢竟 Mac 設計美觀,簡單好用,沒有病毒。那麼為什麼專業人士也對 Mac 情有獨鐘呢?從個人使用經驗來看我想有下面幾個原因:1、MacOS X 是基於 Unix 的這一點太重要了,尤其是對開發人員,至少對於我來說很重要,這意味著Unix 下一堆好用的工具都可以隨手撿到。如果你是個 windows 開發人員,我想你會在 windows 上裝一套cygwin 環境吧?你不用 flex/yacc,
Time of Update: 2016-07-25
/** * Detect upload file type * 檢測上傳檔案的excel檔案類型 * @param array $file * @return bool $flag * @site bbs.it-home.org */ private function detectUploadFileMIME($file) { // 1.through the file extension judgement 03 or 07 $flag = 0
Time of Update: 2016-07-25
本文分享幾段php代碼,分別用於擷取百度快照時間、百度收錄情況、百度熱詞。有需要的朋友作個參考。用php擷取百度快照、百度收錄、百度熱詞,供大家參考。1,擷取百度收錄 2,擷取百度的熱詞 (.*)/is', $templateRss, $_description)) { $templateRss = $_description [0]; $templateRss = str_replace("&", "&", $templateRss); } $templateRss = "" .
Time of Update: 2016-07-25
本文介紹下,隱藏php頭部的版本輸出x-powered-by的方法,有需要的朋友參考下。在php程式中,預設會輸出header資訊:(Status-Line) HTTP/1.1 200 OKDate Wed, 23 Feb 2011 02:30:46 GMTServer Apache/2.2.13 (Win32)X-Powered-By: PHP/5.2.3Content-Length 30Keep-Alive timeout=5, max=100Connection
Time of Update: 2016-07-25
/*** 去除重複的圖片檔案* by bbs.it-home.org*/exec("find . -type f", $lines);$arr = array();$del = array();$n = 0;foreach($lines as $line){ $line = trim($line); if(!$line){ continue; } $n ++; $md5 = md5_file($line); if(isset($arr[$md5])){ $del[] = $line; //
Time of Update: 2016-07-25
分析下php中三個等號===與二個等號==,在比較運算上的區別,有需要的朋友參考下。近日,想研究下php中”===”和”==”的具體區別。其實”===”也是作比較用的,只是比較時要求更嚴格。會要求比較兩邊類型也是一樣的;如:$a=8時;if($a==8.0)或者if($a==8) 都是返回TRUE的;但if($a===8.0) 返回的false,
Time of Update: 2016-07-25
$im = imagecreate(200,150);echo $im;?>//輸出Resource id #1複製代碼二,magecreatetruecolor - 建立一個真彩色的畫布1,格式:imagecreatetruecolor ( int x_size, int y_size )2,解析:同imagecreate一樣,建立一個空白的畫布,區別在於這個函數建立的畫布支援的色彩數更多,所以效果更好,傳入畫布寬度和高度的像素值,返回的是系統分配給這塊畫布的id號,例如: $im =
Time of Update: 2016-07-25
$dataArray="";$nameArray="";$dataArray = "10,20,30,40,50";$nameArray = "一月,二月,三月,四月,五月";echo "";?>$dataArray="";$nameArray="";$dataArray = "10,20,30,40,50,20,30,40,50,20,30,40,50";$nameArray = "一月,二月,三月,四月,五月,二月,三月,四月,五月,二月,三月,四月,五月";echo
Time of Update: 2016-07-25
function validation_filter_id_card($id_card){ if(strlen($id_card)==18){ return idcard_checksum18($id_card); }elseif((strlen($id_card)==15)){ $id_card=idcard_15to18($id_card); return idcard_checksum18($id_card); }else{ return false; }}// 計算身份證校正碼,
Time of Update: 2016-07-25
public function getimgsinarticle($content) { $temp = array(); $imgs = array(); preg_match_all('/http[^\d]*[\d]+[\.](jpg|gif|png)/',$content,$temp); $temp = $temp[0]; if(!empty($temp[0])) { for($i=0;$i { $imgs[$i] = pathinfo($temp[$i]);
Time of Update: 2016-07-25
/*** 計算剩餘時間* by bbs.it-home.org*/public function gettime($time_s,$time_n){$time_s = strtotime($time_s);$time_n = strtotime($time_n);$strtime = '';$time = $time_n-$time_s;if($time >= 86400){return $strtime = date('Y-m-d H:i:s',$time_s);}if($time >= 36
Time of Update: 2016-07-25
複製代碼------解答-------- 第二個沒有做過,關注此問題。 第三個問題: 最簡單的,可以執行mysqldump命令。 $database="";//備份的資料庫名稱$user="";//資料庫連接使用者名稱$password="";//資料庫密碼$outputfile="";//匯出的備份的SQL檔案路徑 system($mysqldump." -u".$user." -p".$password." ".$database." > ".$outputfile."");?>複製代碼--