Time of Update: 2016-07-25
/** 預設首頁 **/ class DefaultController extends AppController { public function index() { $len = 5; $str = "ABCDEFGHIJKLNMPQRSTUVWXYZ123456789";$im = imagecreatetruecolor ( 70, 20 ); $bgc = imagecolorallocate($im, 255, 255, 255); $bgtxt =
Time of Update: 2016-07-25
$ua=parse_url("http://username:password@hostname/path?arg=value#anchor"); print_r($ua);複製代碼結果: Array ( [scheme] => http [host] => hostname [user] => username [pass] => password [path] => /path [query] => arg=value
Time of Update: 2016-07-25
//串連資料庫$con = mysql_connect("localhost","root","");mysql_select_db("xueshengchu",$con);mysql_query("set names utf8"); $pageSize = 5; //每頁顯示資料條數 $result = mysql_query("select * from stu_msg");$totalNum = mysql_num_rows($result); //資料總條數
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
select * from table limit 0,10 // 前10條記錄 select * from table limit 10,10 // 第11至20條記錄 select * from table limit 20,10 // 第21至30條記錄 …… 複製代碼這一組sql語句其實就是當$pagesize=10的時候取表內每一頁資料的sql語句,我們可以總結出這樣一個模板:select * from table limit ($currentpageid - 1) *
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
/*author:默默date :2006-12-03*/$page=isset($_get['page'])?intval($_get['page']):1; //這句就是擷取page=18中的page的值,假如不存在page,那麼頁數就是1。$num=10; //每頁顯示10條資料$db=mysql_connect("host","name","pass"); //建立資料庫連接$select=mysql_select_db("db",$db);
Time of Update: 2016-07-25
$pages = range(1, 100); 記錄數$page_list['end'] = (count($pages) / 10) ? ceil((count($pages) / 10)) : 0; //總頁數 最後頁數$step = isset($_GET['step']) ? $_GET['step'] : 5; //步長 $curr_page = isset($_GET['curr_page']) ? $_GET['curr_page'] : 1; //當前頁$page_
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
//建立一個memcache對象執行個體$memcache = new Memcache;if(!$memcache->connect("127.0.0.1",11211)){ die('串連失敗');}if($memcache->set('key1',"xian",MEMCACHE_COMPRESSED,60)){ echo 'sucess!';}//存值,其中xian字串,也可以為數組,對象,但不能為資源// bbs.it-home.org$val =
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
$src_path = '1.jpg'; //建立源圖執行個體 $src = imagecreatefromstring(file_get_contents($src_path)); //裁剪開地區左上方的點的座標 $x = 100; $y = 12; //裁剪地區的寬和高 $width = 200; $height = 200; //最終儲存成圖片的寬和高,和源要等比例,否則會變形 $final_width = 100; $final_height = round(
Time of Update: 2016-07-25
session_start();//隨機產生驗證碼的字串function random($len) { $srcstr="ABCDEFGHIJKLMNPQRSTUVWXYZ123456789"; mt_srand(); $strs=""; for($i=0;$i $strs.=$srcstr[mt_rand(0,33)]; } return ($strs);}$str=random(5); //隨機產生的字串$width=60; //驗證碼圖片的寬度$height=25;
Time of Update: 2016-07-25
$Shortcut = "[InternetShortcut] URL=http://www.leduz.com/#shortcut IconFile=http://www.leduz.com/faviconbig.ico IconIndex=1 IDList= [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2 "; Header("Content-type: application/octet-stream");
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
$page=isset($_GET['page']) ? intval($_GET['page']) : 1; //擷取page=18中的page的值,假如不存在page,那麼頁數就是1。 $num=10; //每頁顯示10條資料 $db=mysql_connect("host","name","pass"); //建立資料庫連接 $select=mysql_select_db("db",$db); //選擇要操作的資料庫
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
$conn = @mysql_connect("localhost","root","") or die("錯誤串連");mysql_select_db("nettext",$conn);mysql_query("set names 'gbk'");(關鍵代碼)function htmlcode($contect){$contect = str_replace("\n", "", str_replace(" ", " ", $contect));$contect =
Time of Update: 2016-07-25
php;toolbar:false">/*public function actionReport(){$sql = "select * from {{goods}}";$criteria=new CDbCriteria();$result = Yii::app()->db->createCommand($sql)->query();$pages=new