Time of Update: 2016-07-25
操作mysql資料庫的php類 ///////////////////資料庫連接類////////////////////class connect{private $host;//主機名稱private $name;//使用者名稱private $pass;//密碼private
Time of Update: 2016-07-25
在很多部落格上都有很多類似,評論:xx分xx秒,顯示評論的時間長,今天利用php 的date_diff做了一個.
Time of Update: 2016-07-25
functiontest($i){$i-=4; if($i{return $i;}else{test($i);}}echotest(30);?> 複製代碼以上代碼好像沒有問題,其實有else裡面是有問題的。在這裡執行的test沒有傳回值,雖然滿足條件$i下面採用PHP遞迴函式加上傳回值的方法,注意看代碼中的注釋部分與上面的代碼有何不同: function test($i){$i-=4; if($i{return $i;}else{return
Time of Update: 2016-07-25
/**desc:數組遞迴求和link:bbs.it-home.orgdate:2013/2/22*/function arraySumRecursive($array){ $total = 0; foreach(new recursiveIteratorIterator( new recursiveArrayIterator($array)) as $num) { $total += $num; } return $total;}/*** a flat array
Time of Update: 2016-07-25
//strstr函數 $email = 'liruxing1715@sina.com@qq.com'; $domain = strstr($email, '@'); echo "strstr 測試結果:{$domain}"; $domain = strstr($email, '@', true); echo "strstr 測試結果:{$domain}"; /* 測試結果為: strstr 測試結果:@sina.com@qq.com strstr 測試結果:liruxing1715
Time of Update: 2016-07-25
php的require()與include(),在效能方面並無大的不同。僅有的一些不同在於:include()執行時檔案每次都要進行讀取和評估;require()執行時檔案只處理一次(實際上,檔案內容替換了require()語句)。php的require()與include(),在效能方面並無大的不同。僅有的一些不同在於:include()執行時檔案每次都要進行讀取和評估;require()執行時檔案只處理一次(實際上,檔案內容替換了require()語句)。即如果有包含這些指令之一的代碼和可能
Time of Update: 2016-07-25
//---樣本$url = “http://www.163.com”;$data = file_get_contents($url);$data = my_encoding($data,”utf-8″);echo “$data”;//--函數function my_encoding($data,$to){$encode_arr = array(‘UTF-8′,’ASCII’,'GBK’,'GB2312′,’BIG5′,’JIS’,'eucjp-win’,’sjis-win’,'EUC-JP’);
Time of Update: 2016-07-25
class Crypt3Des{private $key = "";private $iv = "";/*** 構造,傳遞二個已經進行base64_encode的KEY與IV** @param string $key* @param string $iv*/function __construct ($key, $iv){if (empty($key) || empty($iv)) {echo 'key and iv is not valid';exit();}$this->key =
Time of Update: 2016-07-25
/** * @author seraphim * @copyright 2013 * url: http:bbs.it-home.org*/ $ADMIN = array( 'defaulturl'=> 'http://www.xx.com/images/banner-header.gif', //盜鏈返回的地址 'url_1' => 'http://www.xx.net/file', 'url_2' => 'http://www.xx.net/file1', ); $okaysites =
Time of Update: 2016-07-25
$sql3="CREATE TEMPORARY TABLE atmp_table(uid int(11),dnum int(20) not null)"; mysql_query($sql3); $sql3="INSERT into atmp_table(uid,dnum) SELECT uid,count(soid) as dnum FROM `cy_score2` where (nei='下載' or nei='下載試題')
Time of Update: 2016-07-25
php將$arr 二維數組的所有第二層合并後返回 array_merge() 將一個或多個數組的單元合并起來,一個數組中的值附加在前一個數組的後面。返回作為結果的數組。 但是只能合并第一層,卻無法合并二級數組的二維部分 我寫了點代碼,感覺很不好,希望高手指更好的方法 $arr=array("0" => array("44" => array("id" => 44,"
Time of Update: 2016-07-25
$conn = mysql_pconnect($host,$user,$pwd);mysql_select_db($dbname,$conn); $result=mysql_query("select * from table_name where col_id ='test_id'", $conn);$result_detail=mysql_fetch_array($result);$item = $result_detail['col_id'];?>複製代碼備忘:作為高並發處理資料庫請求時,
Time of Update: 2016-07-25
php二維數組應用舉例-根據條件取資料,假如數組$point_arr(如下),請取出 user_id = 3的那一行數組。php二維數組應用舉例-根據條件取資料,假如數組$point_arr(如下),請取出 user_id = 3的那一行數組。1,"id"=>1,"point"=>2), array("id"=>2,"id"=>3,"point"=>2), array("id"=>3,"id"=>3,"point"=>2), array("id"=>4,"id"=>3,"point"
Time of Update: 2016-07-25
在這次調查中,從事java開發的開發人員佔總調查對象的51.27%,因此這也使得對java語言使用方式的調查也相對更準確一些。調查結果顯示,在Java開發人員中,使用最多的JDK版本是JDK1.6和JDK1.7,這兩個版本使用率佔總調查資料的88.26%。在應用伺服器的使用上,Java開發主要使用的是Tomcat,佔據高達75%的比例,排名跟二的Oracle Weblogic有10.12%,而Jboss AS和IBM
Time of Update: 2016-07-25
在生產環境中,一個巨大無比的form,包括三張圖片,幾百個輸入框,近一千個checkbox,在用post方法提交到後台時,資料被攔腰截斷。在生產環境中,一個巨大無比的form,包括三張圖片,幾百個輸入框,近一千個checkbox,在用post方法提交到後台時,資料被攔腰截斷。一路打debug,發現PHP 拿到 $_POST時,資料就不足。一開始以為是php中的post_max_size, upload_max_size的問題, 但是設成100M也不管用。後來又以為是Apache
Time of Update: 2016-07-25
簡潔才是王道.... function genTree($items,$id='id',$pid='pid',$son = 'children'){$tree = array(); //格式化的樹$tmpMap = array(); //臨時扁平資料foreach ($items as $item) {$tmpMap[$item[$id]] =
Time of Update: 2016-07-25
由於搞了個群發郵件的程式,當然沒郵箱不行,所以寫了個採集郵箱程式. 轉載自: http://www.tongqiong.com/read.php?tid-35-ds-1.html //作者:www.tongqiong.com$url='http://www.tongqiong.com/read.php?tid-1-ds-1.html'; //這個網頁裡絕對含有郵件地址。$
Time of Update: 2016-07-25
在php中,heredoc文法為輸出大量文本提供了一種非常便利的方式。它不是使用雙引號或單引號來界定字串,而是採用了兩個相同的首尾標識符。在php中,heredoc文法為輸出大量文本提供了一種非常便利的方式。它不是使用雙引號或單引號來界定字串,而是採用了兩個相同的首尾標識符。來看下面的例子:以上樣本,有幾個值得注意的地方:
Time of Update: 2016-07-25
我們知道很多開源軟體的無限分類都是採用遞迴的演算法,但是我們知道遞迴即浪費時間,又浪費空間(記憶體), 上次我也分享了個我自己原創的無限分類產生樹的方法,一熱心php高手網友給我提出了寶貴的建議,我測試了一下,這段代碼的時間非常之短,參考:
Time of Update: 2016-07-25
$people = array("Peter", "Joe", "Glenn", "Cleveland");if (in_array("Glenn",$people)){echo "Match found";}else{echo "Match not found";}?>複製代碼輸出:Match found例2: $people = array("Peter", "Joe", "Glenn", "Cleveland", 23);if (in_array("23",$people, TRUE)){