Time of Update: 2016-07-25
function myfunc(){static $int;$int=0;echo $int+1."";}echo myfunc();echo myfunc();echo
Time of Update: 2016-07-25
/************************************** file: class.paging.php php分頁類代碼**************************************/class paging{ var $sql_results;var $sql_query; var $display_offset;var $display_limit;var $display_limit_URI;var $display_currentpage;var
Time of Update: 2016-07-25
// 分頁/*** $pageType 分頁類型 1是數字分頁 2是文本分頁* 可以將$pageTotal,$page,$total等資料作為參數傳遞,或者在paging作為全域變數(推薦)*/function paging($pageType){global $pageTotal,$page,$total;if($pageType == 1){echo '';echo'';for($i=0; $i { if($page == ($i+1)){echo
Time of Update: 2016-07-25
$arr = array('a','b','c','d');unset($arr[1]);print_r($arr);?>複製代碼結果:Array ( [0] => a [2] => c [3] => d ) 如何做到缺少的元素會被填補並且數組會被重新索引?答案是array_splice():例子: $arr = array('a','b','c','d');array_splice($arr,1,1);print_r($arr);?> 複製代碼結果:Array ( [0] => a [1] =
Time of Update: 2016-07-25
時不時地我們可以聽到有人在說,我們需要更多的程式員。現在的孩子應該在學校裡就學習編程。編程的地位就應該像曾經的寫作文一樣。我不同意這樣的觀點每個領域都會有一些人登上金字塔的頂端,成為這一行業的權威,更多的人則只能被稱為優秀,當然更多更多的人位於平均水平,庸庸碌碌,以及,還有一些人就像溺水之人一樣在苦苦掙紮。讓我們面對現實吧,並不是每個人都適合每一份工作。正如大多數程式員成不了銷售、演員、醫生和律師,同樣的,大多數律師、演員和銷售也幹不了程式員的工作。萬金油型的天才總是很稀少的。如果你硬是要將更多
Time of Update: 2016-07-25
本文介紹了codeigniter資料庫緩衝自動到期的處理辦法,修改了一下db類,在開啟緩衝時設定一個到期時間,到期自動緩衝自動失效。codeigniter資料庫緩衝自動到期codeigniter架構是一個非常小巧的php架構,最近幾個項目中一直用。ci內建資料庫檔案緩衝,但按官方的說法,緩衝設定後永不到期,出發你調用方法主動刪除。cache files do not expire. any queries that have been cached will remain cached
Time of Update: 2016-07-25
//定每頁顯示多少條//count(*)查詢總條數//計算總頁數ceil()//判斷$_GET 並賦值當前頁數//mysql查詢 limit (當前頁數-1)*每頁條數,每頁條數//如果總條數不為空白,進行迴圈mysql_fetch_array()//$_SERVER['PHP_SELF']//上一頁?page=當前頁-1//下一頁?page=當前頁+1//edit: bbs.it-home.orginclude("conn.php"); $perpagenum = 3;$total =
Time of Update: 2016-07-25
if ($_get['count']) {$count = $_get['count'];} else {$count =select count(*) from tablename where …..}
Time of Update: 2016-07-25
include("conn.php"); //資料庫連結,自己解決 $sql="select * from news";$query=mysql_query($sql);$all_num=mysql_num_rows($query); //總條數$page_num=3; //每頁條數$page_all_num = ceil($all_num/$page_num); //總頁數$page=empty($_GET['page'])?1:$_GET['page']; //當前頁數$page=(int)
Time of Update: 2016-07-25
/*******分頁原理*********/ //每頁顯示記錄條數 $page_size = 3; $sql = "select * from message"; $result = mysql_query($sql); //總記錄條數 $num = mysql_num_rows($result); //總頁面數量的計算 if($numif($num%$page_size) { $page_count = intval($num/$page_size)+1 ;} if($num%
Time of Update: 2016-07-25
include "pager.class.php"; $CurrentPage=isset($_GET['page'])?$_GET['page']:1; //die($CurrentPage); $myPage=new pager(1300,intval($CurrentPage)); $pageStr= $myPage->GetPagerContent(); //echo $pageStr; $myPage=new pager(90,intval($CurrentPage));
Time of Update: 2016-07-25
本文介紹了php正則不包含某字串的寫法,Regex不包含指定的字串的例子,有需要的朋友參考下。在php編程中,匹配字串的常見函數 strstr($str, “abc”); 正則匹配preg_match(”/(abc)?/is”, $str); 但是要匹配一個字串中,不包含某字串,用正則就比較麻煩了 如果不用正則 !strstr($str, “abc”); 即可解決問題。命名用正則可以這樣: ”/^((?!abc).)*$/is”例子: 結果為:false,含有abc! $str = “2b3
Time of Update: 2016-07-25
/***************************** * @類名: page * @參數: $myde_total - 總記錄數 * $myde_size - 一頁顯示的記錄數 * $myde_page - 當前頁 * $myde_url - 擷取當前的url * @功能: 分頁實現 * @作者: 宋海閣 */class page {private $myde_total; //總記錄數private $myde_size;
Time of Update: 2016-07-25
/*** PHP分頁代碼* *//*** 連結資料庫* bbs.it-home.org* @param string $strHost 資料庫伺服器主機地址* @param string $strAccount 資料庫帳號* @param string $strPassword 資料庫密碼* @return resource* */function mysqlConnect($strHost,$strAccount,$strPassword,$strDBname){ $strHost=trim(
Time of Update: 2016-07-25
class Child{public $name; //定義並初始化一個靜態變數 $nums 參考連結:php靜態變數初始化public static $nums=0; function __construct($name){$this->name=$name; }public function join_game(){//self::$nums 使用靜態變數 self::$nums+=1;echo $this->name."加入堆雪人遊戲"; } }//建立三個小孩 $child1=new
Time of Update: 2016-07-25
$conn = @ mysql_connect("localhost", "root", "123456") or die("資料庫連結錯誤");mysql_select_db("bbs", $conn);mysql_query("set names 'gbk'"); //使用gbk中文編碼;//將空格,換行轉換為html可解析function htmtocode($content) { $content = str_replace("\n", "", str_replace(" ", " ",
Time of Update: 2016-07-25
# tar -xzf libevent-1.1a.tar.gz # cd libevent-1.1a # ./configure --prefix=/usr # make # make install # cd .. # tar -xzf memcached-1.1.12.tar.gz # cd memcached-1.1.12 # ./configure --prefix=/usr # make # make install複製代碼安裝完成之後,memcached 應該在
Time of Update: 2016-07-25
本文介紹了php類中靜態方法與靜態變數的用法區別,如果是非靜態方法,需要改方法中沒有使用$this,即沒有調用非靜態變數/方法,當然,調用靜態變數/方法沒有問題。有關php靜態方法與靜態變數的用法。在php中,訪問類的方法/變數有兩種方法:1、建立對象$object = new
Time of Update: 2016-07-25
/** * 分頁類 */class Pager { var $total; // 記錄總數 var $pageSize; // 每一頁顯示的記錄數 var $currentPage; // 當前頁碼 var $offset; // 記錄位移量 var $pageTotal; // 總頁數 var $numberOffset = 5; // 頁碼位移量 var $request = ""; // 頁面請求參數//=================
Time of Update: 2016-07-25
//php分頁類代碼class page{ public $page; //當前頁 public $pagenum; // 頁數 public $pagesize; // 每頁顯示條數 public function __construct($count, $pagesize){ $this->pagenum = ceil($count/$pagesize); $this->pagesize = $pagesize; $this->page =(isset($_GET['p'])&&$