Time of Update: 2016-07-25
本文介紹下,用php實現隔行變色的一段代碼,有需要的朋友參考下。在php編程中,最常見的一個實現就是動態輸出資料,尤其是輸出以表格顯示的資料。資料來源可以是xml檔案,可以是資料庫表中的資料,也可以是其它類型的資料,如csv、xls等。如何以方便使用的方式顯示這些資料,有時是個問題。以隔行變色的方式顯示數量較大的資料時,不失為一個好辦法,結合css樣式來實現。可以讓資料更清晰易讀,更直觀。下面分享的這段代碼,可以實現如上的功能,如下:隔行變色bbs.it-home.org-程式員之家'.$cri
Time of Update: 2016-07-25
分享一個php實現的email檢測類,同樣是用到了php正則,簡單實用,有需要的朋友參考下。php實現的email檢測類,判斷email格式的正確性。代碼:success_txt=$success_txt; $this->error_txt=$error_txt; } function start_check($params){ $this->email=$params; if(preg_match($this->exp,
Time of Update: 2016-07-25
本文介紹下,php使用phpexcel匯出資料的一段代碼,有需要的朋友,不妨作個參考,希望對大家有所協助。使用phpexcel類庫,實現匯出資料,代碼如下:getActiveSheet()->setCellValue('a1','Key'); $obj_phpexcel->getActiveSheet()->setCellValue('b1','Value'); if($data){ $i =2;
Time of Update: 2016-07-25
本文介紹一段php代碼,用於上傳pdf檔案到網站空間中,有需要的朋友參考下。使用php上傳pdf格式的檔案。1,html部分2,上傳pdf檔案的代碼,需要做檔案格式的檢測,這裡是:application/pdf。請上傳 PDF 格式的檔案."; } else { $name = $_POST['name']; $result = move_uploaded_file($_FILES['classnotes']['tmp_name'], filesplace."/$name.pdf"); if (
Time of Update: 2016-07-25
為大家分享一個php 雲標籤的代碼,現在這個很流行的哦,有需要的朋友參考下吧。在如今的php網站中,雲標籤的大量應用,使頁面顯得生效而有趣,也增加了相關內容的索引與檢索。本節分享一段php 雲標籤的實現代碼,有興趣的朋友,可以研究下。1,css代碼部分2,php 雲標籤的展示部分40, 'tagname' =>'tutorials', 'url'=>'http://bbs.it-home.org/tutorials/'), array('weight' =>12,
Time of Update: 2016-07-25
本文介紹下,在php中截取中文字串無亂碼的二個函數,分別是ord()函數與substr()函數。有需要的朋友參考下。在php編程中要注意:根據UTF-8編碼規範,將3個連續的字元計為單個字元。來看一段截取中文字串的代碼,如下:=224) //如果ASCII位高與224, { $returnstr=$returnstr.substr($sourcestr,$i,3); //根據UTF-8編碼規範,將3個連續的字元計為單個字元 $i=$i+3
Time of Update: 2016-07-25
/*** php 冒泡排序* edit by bbs.it-home.org*/ function maopao($arr){ $c = count($arr); $t = 0; for($i=0;$i for($j=$i+1;$j if($arr[$i] { $t = $arr[$i];
Time of Update: 2016-07-25
本文分享一個用於統計檔案行數的php代碼,不是採用file()函數,而是通過自訂的函數,使用fopen系列函數來實現該功能。希望對大家有所協助。在php中,如果要統計檔案的行數,對於小檔案而言,使用file()函數是最方便的。不過對於大檔案而言,採用file()函數,就會效率很低,因為該函數會一次性把資料讀取到一個數組中,然後儲存在記憶體中。由於php記憶體的限制,此方法處理大檔案時,會效率極低,且容易出錯。本文介紹的這個方法,通過逐行遍曆檔案,可以處理任意大小的檔案,而不用考慮記憶體限制的問題
Time of Update: 2016-07-25
本文介紹下,一個功能強大的php cookie操作類,可以完成設定cookie、擷取cookie值、刪除cookie值等操作,有需要的朋友參考下。分享一個php cookie操作的類,可以設定cookie、擷取cookie、刪除cookie。代碼:_name=$cname; if($cexpires){ $this->_expires=$cexpires; } else{ $this->_expires=time() + 60*60*24*30*12; // ~12 months } $
Time of Update: 2016-07-25
本文介紹下,php中的mysql_fetch_array()函數的用法,它以數組形式返回資料查詢結果。有需要的朋友參考下。php資料查詢結果函數:mysql_fetch_array()函數。以數組方式返回資料查詢結果。文法: array mysql_fetch_array(int result, int [result_typ]); 傳回值: 數組 函數種類: 資料庫功能 本函數用來將查詢結果 result 拆到陣列變數中。若 result 沒有資料,則返回 false 值。 本函數為
Time of Update: 2016-07-25
class Foo { function name_none_static(){ echo "My name is " . get_class() . ""; echo "My name is " . get_class($this) . ""; } } //類內部調用 $bar = new Foo(); $bar->name_none_static(); //類外部調用 echo "Its name is
Time of Update: 2016-07-25
[root@jbxue /]# curl -I bbs.it-home.orgHTTP/1.1 200 OKServer: nginxDate: Tue, 20 Jul 2010 05:45:13 GMTContent-Type: text/html; charset=UTF-8Connection: keep-aliveVary: Accept-Encoding 複製代碼已隱藏了PHP版本。2、其它幾個PHP的基本安全設定: disable_functions =
Time of Update: 2016-07-25
print number_format(100000.56 );?>複製代碼例2,number_format($n, $p, $t, $d) rounds $n to $p decimal places, using $t as the thousands separator and $d as the decimal separator. echo "Total charge is ", number_format($total, 2, ".", ","), "
Time of Update: 2016-07-25
//php 不同系統的換行 //不同系統之間換行的實現是不一樣的 //linux 與unix中用 /n //MAC 用 /r // bbs.it-home.org//window 為了體現與linux不同 則是 /r/n //所以在不同平台上 實現方法就不一樣 //php 有三種方法來解決 //1、使用str_replace 來替換換行 $str = str_replace(array("/r/n", "/r", "/n"), ""
Time of Update: 2016-07-25
/*** php自動產生關鍵字的內鏈* by bbs.it-home.org*/include_once(dirname(__file__)."/../db/DBViewSpot.php" );class InnerLink{ private static $spotUrlMap; /** * Generate view spots keywords link * * @param string $description * @param array
Time of Update: 2016-07-25
/*** 上傳檔案 建立遞迴目錄* edit:bbs.it-home.org*/$uid=$_REQUEST['uid'];$avatar = 'D:/www/discuz/uc_server/data/avatar/'.get_avatar($uid, $size, $type);$dir=dirname($avatar);//建立目錄成功後移動臨時檔案if(mkdirs($dir)){ if($_FILES["pic"]["error"] >=
Time of Update: 2016-07-25
exec("mkdir d:\\test",$out);print_r($out);?> 複製代碼執行該php檔案,會發現在d盤下多了一個test檔案夾。參考文檔:exec函數解析exec文法: string exec(string command, string [array], int [return_var]);exec傳回值: 字串exec參數說明Command – 需要執行的命令Array – 是輸出值return_var
Time of Update: 2016-07-25
//這是b.phpinclude a.phpsession_start();?> 複製代碼之前看到很多php檔案中都不帶php的結束符,今天看到看到一個demo,也剛好解釋了不用?>結束符的好處。以下是a.php: 注意第四行,第五行) include 的檔案.phpsession_start();?> 複製代碼運行第二個檔案,就會發現它會拋出警告說header already send
Time of Update: 2016-07-25
本文介紹下,php在查詢字串中傳遞值的方法,舉了二個例子,分別用來傳遞字串值、數字值。有需要的朋友,參考下吧。例1,在查詢字串中傳遞字串值 Click a link to move to a new page: Content 1 Content 2 Content 3 很抱歉,您請求的頁面不存在。"; } } ?> 例2,在查詢字串中傳遞數值查詢字串傳遞數值-bbs.it-home.org Click a link
Time of Update: 2016-07-25
本文介紹下,php中全域變數$_SERVER的例子,有需要的朋友參考下。例1,迴圈列出全域變數$_SERVER中的值 $value) { echo "$var => $value ";}?>例2,取檔案的最後更新時間例3,取檔案的更新日期與時間例4,網站的環境變數資訊