Time of Update: 2016-07-25
array(11) { [0]=> string(15) "HTTP/1.1 200 OK" [1]=> string(35) "Content-Type: text/html;charset=gbk" [2]=> string(17) "Connection: close" [3]=> string(13) "Server: nginx" [4]=> string(35) "Date: Fri,
Time of Update: 2016-07-25
/** * 通用驗證碼類 img.php * 版本:V0.1 * bbs.it-home.org 2013/3/1 */ class ValidateCode { private $charset="abcdefghizklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; //隨機因子 private $code; //驗證碼文字 private $codelen=4;
Time of Update: 2016-07-25
include("./class/class.php"); // 包含class的基本標頭檔include("./class/phpexcel/PHPExcel.php"); // 產生excel的基本類定義(注意檔案名稱的大小寫)// 如果直接輸出excel檔案,則要包含此檔案include("./class/phpexcel/PHPExcel/IOFactory.php");// 建立phpexcel對象,此對象包含輸出的內容及格式$m_objPHPExcel = new PHPExcel(
Time of Update: 2016-07-25
/** php產生強密碼 linK:bbs.it-home.org 2013/3/2*/$password_length = 9;function make_seed() {list($usec, $sec) = explode(’ ‘, microtime());return (float) $sec + ((float) $usec * 100000);}srand(make_seed());$alfa =
Time of Update: 2016-07-25
解決php session跨頁面傳遞 session值丟失的問題,有遇到這個問題的朋友,參考下。session的運行機制:解決php session跨頁面傳遞
Time of Update: 2016-07-25
/** @ 設定及保留屬性的類 @ class cleanHtml @ link:bbs.it-home.org @ date:2013/2/28*/ function reg_escape( $str ) { $conversions = array( "^" => "\^", "[" => "\[", "." => "\.", "$" => "\$", "{" => "\{", "*" => "\*", "(" => "\(", "\\" => "
Time of Update: 2016-07-25
//截取中文字串function mysubstr($str, $start, $len) {$tmpstr = "";$strlen = $start + $len;for($i = 0; $i if(ord(substr($str, $i, 1)) > 0xa0) {$tmpstr .= substr($str, $i, 2);$i++;} else$tmpstr .= substr($str, $i, 1);}return $tmpstr;}?>複製代碼2、截取utf8編碼的多位元組字串/
Time of Update: 2016-07-25
/* 從字典檔案中提取隨機值 */$file1 = "./Words.dic";$file2 = "./common_pass_mini.dic";$file3 = "./Sys_Month_Date.Dic";$rfile = "./5.dic";$n = 2000;//提取字典$basef = file($file1);$extf = file($file2);$extf2 = file($file3);$bf_sum = (count($basef)-1);$ef_sum =
Time of Update: 2016-07-25
$url = "http://bbs.it-home.org/";$ctx = stream_context_create(array('http' => array('timeout' => 5,'proxy' => 'tcp://60.175.203.243:8080','request_fulluri' => True,)));$result = file_get_contents($url, False, $ctx);echo $result;?>複製代碼2、curl 代理的方法:
Time of Update: 2016-07-25
class ArrayToXML{ /** * The main function for converting to an XML document. * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document. * * @param array $data * @param string
Time of Update: 2016-07-25
$idlist='';for($i=1;$iif($i==1){$idlist=mt_rand(3,25216);}else{$idlist=$idlist.','.mt_rand(3,25216);}}$query="select * from table where id in ($idlist) LIMIT 0,10";?>複製代碼原理分析:產生一組隨機ID,然後檢索這一組ID對應的記錄。經過這樣最佳化,頁面開啟速度明顯快了很多,CPU佔用率也小到幾乎為0。順便用這個思路把sql
Time of Update: 2016-07-25
function jsontest(){var json = [{'username':'crystal','userage':'20'},{'username':'candy','userage':'24'}];alert(json[1].username);var json2 = [['crystal','20'],['candy','24']];alert(json2[0][0]);}複製代碼這個函數,第一個alert(json[1].username); 會提示 “candy”。
Time of Update: 2016-07-25
header("content-type:text/html; charset=utf-8"); //指定PHP使用UTF-8編碼$xml = simplexml_load_file("example.xml"); //讀取xml檔案$newxml = $xml->asXML(); //標準化$xml$fp = fopen("newxml.xml", "w"); //建立xml檔案fwrite($fp, $newxml);
Time of Update: 2016-07-25
php 多圖片上傳的簡單例子,只為初學的朋友參考,程式員之家出品。未經允許,禁止轉載。php 多圖片上傳的簡單例子,供初學的朋友參考。指令碼學堂出品,未經允許,禁止轉載。1、圖片上傳前台頁面 upload.html注意 input type=file 和 enctype="multipart/form-data",這是php檔案上傳的關鍵。2、處理多檔案上傳的程式 do_upload.php 以下示範具體的上傳過程:step1:step2:
Time of Update: 2016-07-25
//判斷瀏覽器類型echo $_SERVER["HTTP_USER_AGENT"]; //判斷瀏覽器語言echo $_SERVER["HTTP_ACCEPT_LANGUAGE"]; ?>複製代碼下面是兩個完整的樣本,分別判斷瀏覽器類型、瀏覽器語言。1、判斷瀏覽器類型 if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 8.0"))echo "Internet Explorer 8.0";else
Time of Update: 2016-07-25
for($i = 0; $i $_md_color = imagecolorallocate($_img,mt_rand(0, 255),mt_rand(0, 255), mt_rand(0, 255)); imageline($_img, mt_rand(0, 75), mt_rand(0, 75), mt_rand(0, 75), mt_rand(0, 75),$_md_color); }//隨機雪花for($i = 0; $i $_md_color =
Time of Update: 2016-07-25
介紹:產生隨機使用者名稱與密碼,在php中可以使用 mt_rand或rand函數,現在 rand 函數在驗證碼中用的較多一些,而產生長字元的隨機碼大多還是使用 mt_rand 函數。介紹:產生隨機使用者名稱與密碼,在php中可以使用 mt_rand或rand函數,現在 rand 函數在驗證碼中用的較多一些,而產生長字元的隨機碼大多還是使用 mt_rand
Time of Update: 2016-07-25
//隨機產生六位元密碼Beginfunction randStr($len=6,$format='ALL') { switch($format) { case 'ALL': $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~'; break; case 'CHAR': $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@#~
Time of Update: 2016-07-25
PHP產生excel與控制Excel儲存格中的分行符號公司使用Mantis管理bug, Mantis有一個功能, 將bug匯出為Excel,但是目前的這個mantis版本, 在匯出excel的時候, "摘要,說明,問題重現步驟說明,附加資訊,評論"等等這些資訊中,提交bug時候的斷行符號分行符號都不見了, 因為沒有了格式, 在excel中讀起來很不方便,這回想改善的便是這個問題,在使用php做成excel的時候, 如何在一個excel cell內寫入分行符號, 控制該儲存格的格式.我實驗了一下,
Time of Update: 2016-07-25
select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')複製代碼PHP文章按日期(日)SQL歸檔 select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by