Time of Update: 2017-01-13
代碼如下複製代碼 <?php /** * PHP擷取一組隨機數字不重複 */$a = microtime(); function createRandID($m){ // 產生一個從1到$m的數組 $arr = range(1,$m); // 打亂數組 shuffle ($arr); &
Time of Update: 2017-01-13
se.php 代碼如下複製代碼 <?php$city = $_GET['city'];$data = createXml($city); $xml = simplexml_load_string($data);header("Content-type: text/xml");echo $xml->asXML(); // 產生XML資料function createXml($city){ /
Time of Update: 2017-01-13
功能簡單,直接上代碼。 代碼如下複製代碼 <a href='shortcuts.php'>火星時代IT開發</a> shortcuts.php 代碼 代碼如下複製代碼 $Shortcut = "[InternetShortcut]URL=http://www.111cn.netIDList=IconFile=http://www.111cn.net/favicon.icoProp3=19,2";header(&
Time of Update: 2017-01-13
辦法一、按字數控制進行分頁按字數分頁辦法簡單易用,但效果不好。大致思想:首先、設定每頁能容納的最大字數;然後、計算文章內容的總字數,再由總字數和單頁最大字數計算出出總頁數。這樣整個分頁的準備工作就已經做好了。具體到每一頁的顯示內容可以通過內容截取來實現。比如:頁容納500字,文章內容有2200字,那麼當頁面傳遞page=2時應該顯示第501至1000之間的內容。這種辦法簡單,但顯示時可能會遇到麻煩,文章內容通常伴有HTML標籤,進行內容切割時實現HTML標籤的閉合有一定難度,如果這個工作沒做好,
Time of Update: 2017-01-13
1,php excelreader操作excel的php類,產生,讀取excel等。功能很強大。下載地址:http://sourceforge.net/projects/phpexcelreader/解壓後,裡面有很多例子,調用方法簡單。例1 代碼如下複製代碼 <?php/** * * @copyright 2007-2012 Xiaoqiang. * @author Xiaoqiang.Wu <jamblues@gmail.com&
Time of Update: 2017-01-13
注意:__autoload() 內的錯誤不能被 try-catch 捕獲。 代碼如下複製代碼 function __autoload($class_name){ require_once(PATH.'/calsses/'.$class_name.'.php');}$obj1 = new mycalss1(); 註冊 __autoload() 自動調用的函數:spl 程式碼程式庫在 PHP5.0
Time of Update: 2017-01-13
寫一個函數,將資料 代碼如下複製代碼 $array = array( 0=>array("","河北"), 1=>array("","北京"), 2=>array(0,"保定"),
Time of Update: 2017-01-13
代碼如下複製代碼 <?phpclass listdir{var $depth;var $dirname;var $list;var $tostring;function listdir($dir){$this->dirname=$dir;$this->depth=0;$this->tostring=”";}//把結果儲存進多維陣列function
Time of Update: 2017-01-13
在 PHP 應用中,Regex主要用於:•正則匹配:根據Regex匹配相應的內容•正則替換:根據Regex匹配內容並替換•正則分割:根據Regex分割字串常用preg_match_all()preg_match_all() 函數用於進行Regex全域匹配,成功返回整個模式比對的次數(可能為零),如果出錯返回 FALSE 。文法:int preg_match_all( string pattern, string subject, array matches [,
Time of Update: 2017-01-13
PHP的顯示時間的代碼比ASP還是強大多了,調用起來更加的簡單。先看 代碼如下複製代碼 //系統函數開始$nbyear=Date('Y');$nbmonth=Date('m');$nbday=Date('d');$date=Date('Y-m-d');$datetime=Date('Y-m-d H:i:s');$cndate=Date('Y年m月d日');$cndateweek=Date('Y年m月d日'); 下面我們來一一介紹1、年-月-日echo
Time of Update: 2017-01-13
上傳作業碼 代碼如下複製代碼 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"
Time of Update: 2017-01-13
代碼如下複製代碼 function RecordToJson($recordset) { $jstr='['; while($rs = $recordset->Fetch())
Time of Update: 2017-01-13
is_file 只判斷檔案是否存在; 代碼如下複製代碼 <?php $file = "test.txt"; if(is_file($file)) { echo ("$file is a regular file"); }else { echo ("$file is not a regular file"); } ?> 輸出:test.txt is a regular
Time of Update: 2017-01-13
分享一個實際在用的函數:file_get_contents() 函數是用於將檔案的內容讀入到一個字串中的首選方法。如果作業系統支援,還會使用記憶體映射技術來增強效能。/*比file_get_contents穩定的多!$timeout為逾時時間,單位是秒,預設為1s。*/ 代碼如下複製代碼 function curl_get_contents($url,$timeout=1) { $curlHandle = curl_init();
Time of Update: 2017-01-13
代碼如下複製代碼 <?php/*** Check檢測類*/Class Check{ /** * IsUsername函數:檢測是否符合使用者名稱格式 * $Argv是要檢測的使用者名稱參數 * $RegExp是要進行檢測的正則語句 * 傳回值:符合使用者名稱格式返回使用者名稱,不是返回false */ function
Time of Update: 2017-01-13
1,年-月-日echo date('Y-m-j');2007-02-6echo date('y-n-j');07-2-6大寫Y表示年四位元字,而小寫y表示年的兩位元字;小寫m表示月份的數字(帶前置),而小寫n則表示不帶前置的月份數字。echo date('Y-M-j');2007-Feb-6echo
Time of Update: 2017-01-13
1. 判斷Email: 代碼如下複製代碼 <?phpfunction is_email($email){return strlen($email) > 6 && preg_match("/^[w-.]+@[w-]+(.w+)+$/", $email);}?> 2. 判斷Url: 代碼如下複製代碼 function is_url($str){ return preg_match("
Time of Update: 2017-01-13
代碼如下: 代碼如下複製代碼 function get_between($input, $start, $end) { $substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1)); return
Time of Update: 2017-01-13
1.php 代碼如下複製代碼 <form name=form1 id=form1 method=post action=2.php>基本資料1:<input type=text name=base1 />基本資料2:<input type=text name=base2 /><input type=submit value="下一步"></form> 2.php 代碼如下複製代碼
Time of Update: 2017-01-13
一,關閉notice錯誤提示1、在php.ini檔案中改動error_reporting改為: 代碼如下複製代碼 error_reporting=E_ALL & ~E_NOTICE 2、如果你不能操作php.ini檔案,你可以使用如下方法在你想禁止notice錯誤提示的頁面中加入如下代碼: 代碼如下複製代碼 error_reporting(E_ALL^E_NOTICE);