Time of Update: 2016-07-25
基於redis的自增長計數器,產生自增長數字 /** * 產生自增長數字 * * @param string $key 緩衝key * @param int $step 自增長步長 * @param int $expires 緩衝到期時間,單位秒 * * @return int $num; * @author leeyi */function incr_num($key='ddg', $step=1, $expires=0) { //
Time of Update: 2016-07-25
$postData = array();$postData['data1'] = "testdata1";$postData['data2'] = "testdata2";$postData['data3'] = "testdata3";$url='http://yourdomain/do.php';$str="";foreach ($postData as $k=>$v){ $str.= "$k=".urlencode($v)."&";}$postData=substr($str,0,-
Time of Update: 2016-07-25
蝦囧CMS(仿快樂麻花,臭事百科,內涵段子)笑話程式http://www.topthink.com/topic/13029.html while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($path."/".$file)) { file_list($path."/".$file); } else { //echo
Time of Update: 2016-07-25
官方文檔地址:http://www.golaravel.com/docs/4.1/introduction/系統內容 Mac OSX 10.9.2升級phpbrew updatebrew upgradebrew tap homebrew/dupesbrew tap josegonzalez/homebrew-phpbrew install php55複製代碼安裝composerhttps://getcomposer.org/doc/00-intro.md#globally-on-osx-via-
Time of Update: 2016-07-25
我們可以使用RecursiveDirectoryIterator 和 RecursiveIteratorIterator刪除目錄和子目錄及檔案,子目錄將先與父目錄刪除 function cleanup_directory($dir) { $iter = new RecursiveDirectoryIterator($dir); foreach (new RecursiveIteratorIterator($iter,
Time of Update: 2016-07-25
php程式設計語言的流行來源於開源的思想,PHP也有很多的開來源程式。提到論壇大家想到的可能是PHP開發(http://www.maiziedu.com/course/php/)的Discuz和PHPWind等論壇,其實有時候我們的論壇根本都不需要這麼複雜。下面想大家推薦一些比較好實用的PHP輕論壇程式。1、XiunoXiuno BBS 是國產的一套面向千萬級資料量設計的開源論壇軟體,基於 PHP/MySQL/MongoDB/Memcached/Linux C/JQuery/ 等技術,採用
Time of Update: 2016-07-25
//擷取網域名稱或主機地址 echo $_SERVER['HTTP_HOST'].""; //擷取網頁地址 echo $_SERVER['PHP_SELF'].""; //擷取網址參數 echo $_SERVER["QUERY_STRING"].""; //擷取使用者代理程式 echo $_SERVER['HTTP_REFERER'].""; //擷取完整的url echo
Time of Update: 2016-07-25
下面的代碼示範了php中如何擷取使用者上傳的檔案,並限制檔案類型的一般圖片檔案,最後儲存到伺服器 $allowedExts = array("gif", "jpeg", "jpg", "png");$extension = end(explode(".", $_FILES["file"]["name"]));if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($
Time of Update: 2016-07-25
php計算指定目錄下檔案佔用的空間 php中可以通過 RecursiveDirectoryIterator 擴充 DirectoryIterator的getChildren() 方法提供訪問子目錄中的每一個元素的方法,下面的代碼通過遍曆訪問目錄下的所有檔案,擷取他們暫用的空間。 $dir = new RecursiveDirectoryIterator('C:\wamp');$totalSize = 0;foreach (new RecursiveIteratorIterator($dir)
Time of Update: 2016-07-25
function pageSplit($startPos, $rowsPerPage = '', $totalRows = '' ) { $numPages = $totalRows / $rowsPerPage ; $tenthPages = $rowsPerPage * 10 ; If($startPos >= $tenthPages ) {
Time of Update: 2016-07-25
KEY 是之前定義的常量 Mcrypt::encrypt(); Mcrypt::decrypt(); defined('ROOT') or exit('Access Denied');class Mcrypt{ public static function encrypt($code){ return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(KEY), $code,
Time of Update: 2016-07-25
在python和golang中都有一個函數同時返回多個值的方法,其實php也可以,但相比python和golang要稍微麻煩一點,下面是一個簡單的示範範例,這裡用到了list函數 function retrieve_user_profile() { $user[] = "Jason"; $user[] = "sharejs.com"; $user[] = "English"; return $user; }
Time of Update: 2016-07-25
下面php代碼通過gzcompress和gzuncompress壓縮和解壓縮字串,可以設定壓縮層級 $str = 'Hello I am a very very very very long string';$compressed = gzcompress($str, 9);//壓縮層級為9$uncompressed = gzuncompress($compressed); echo $str, "\n";echo $uncompressed, "\n";echo base64_encode(
Time of Update: 2016-07-25
php寫入資料到CSV檔案範例代碼 $row = 0;ini_set('max_execution_time', 300);$cate;$item;$value;$us;$fp = fopen("torah1.csv", "w");if (($handle = fopen("t.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num =
Time of Update: 2016-07-25
echo date("Ymd",strtotime("now")), "\\n"; echo date("Ymd",strtotime("-1 week Monday")), "\\n"; echo date("Ymd",strtotime("-1 week Sunday")), "\\n"; echo date("Ymd",strtotime("+0 week Monday")), "\\n"; echo date("Ymd",strtotime("+0 week
Time of Update: 2016-07-25
php將linux已耗用時間轉換成更好看的格式 $exec = shell_exec('uptime'); $uptime = explode(' up ', $exec); $uptime = explode(',', $uptime[1]); if (strpos($uptime[0], 'day')) { $time = explode(':', $uptime[1]); echo('Current system uptime is
Time of Update: 2016-07-25
寫在前邊:我們知道現有語言的編程範式有:過程式,物件導向,函數式,邏輯式。隨著軟體工業化程度的普及,以及軟體的複雜度越來越高,程式設計語言的發展曆程也是從最初的過程式(命令式)語言c,發展到以java語言為代表的物件導向程式設計語言。而邏輯程式設計語言(以prolog為代表)和函數式語言(lisp系列)還多用在學術和人工智慧領域中。近幾年,隨著多核,雲端運算時代的到來。函數式程式設計語言逐漸浮出水面,最經典的語言以scheme,common-lisp,ml,clojure,go為代表.而且最近的
Time of Update: 2016-07-25
與關係型資料庫相比,MongoDB的優點:①弱一致性(最終一致),更能保證使用者的訪問速度: 舉例來說,在傳統的關係型資料庫中,一個COUNT類型的操作會鎖定資料集,這樣可以保證得到“當前”情況下的精確值。這在某些情況下,例 如通過ATM查看賬戶資訊的時候很重要,但對於Wordnik來說,資料是不斷更新和增長的,這種“精確”的保證幾乎沒有任何意義,反而會產生很大的延 遲。他們需要的是一個“大約”的數字以及更快的處理速度。
Time of Update: 2016-07-25
//非遞迴擷取所有後代分類function get_offspring($pids, $list){ $npid = array(); $offspring = array(); $has_child = true; while($has_child) { $has_child = false; foreach($list as $lk => $lv) { if(in_array($lv['pid'],
Time of Update: 2016-07-25
class ValidationCode { //屬性 private $width; private $height; private $codeNum; private $image; private $disturbColorNum; //幹擾元素數目 private $checkCode; function