Time of Update: 2018-12-07
function _code($_code_length = 4, $_width = 75, $_height = 25){ for($i=0;$i<$_code_length;$i++){ $_nmsg .= dechex(mt_rand(0,15)); } $_SESSION["code"] = $_nmsg; $_img = imagecreatetruecolor($_width, $_height); $_white =
Time of Update: 2018-12-07
在PHP的官網上看到的parse_url()函數的替代。結果和parse_url()函數差不多,是使用正則實現的,看到好就轉過來。原文:http://www.php.net/parse_url#104958 我就不翻譯了,它可以解析URIURI 是 Web上可用的每種資源 - HTML文檔、映像、視頻片段、程式等 - 由一個通用資源標誌符(Uniform Resource Identifier, 簡稱"URI")進行定位。對就分組: ^(([^:/?#]+):)?(//([^
Time of Update: 2018-12-07
在網上搜了一下,有幾種實現思路,還算實用。此文記錄備用。1. muyu的方案 $(document).ready(function(){ $('#btn').click(function(){ var jsonStr = $('#jsonData').val(); var json = eval('('+jsonStr+')'); (function(){ var print_r = function(o, depth) {
Time of Update: 2018-12-07
1,確保apache支援 mod_rewrite1)開啟Apache2.2\conf\httpd.conf搜尋 LoadModule rewrite_module modules/mod_rewrite.so (Apache2是這個)去掉前面的#2)搜尋AllowOverride None 替換為 AllowOverride All(注意,有好幾個)2,在 CI 根目錄下建立立一個設定檔,命名為: .htaccess,檔案內容如下:RewriteEngine on RewriteCond $
Time of Update: 2018-12-07
實現效果:類似1234567890-->1,234,567,890。代碼://未考慮浮點型/* * method 1 * echo number_format($str,2,'.',','); */ /* method2 * 先反轉字串strrev 再str_split($str,3); $str = strrev($str); $arr = str_split($str,3);//987
Time of Update: 2018-12-07
<?php$input = array("a" => "green","", "red","b" => "green", "","blue", "red","c" => "witer","hello","witer");//$result = array_unique($input); //去除重複元素$result = a_array_unique($input); //只留下單一元素foreach($result as $aa){echo $aa."<br
Time of Update: 2018-12-07
文章目錄 Coding tips I've been coding in PHP ever since I was 13, over the years I have seenmany different coding styles and standards being used. However most ofthem weren't
Time of Update: 2018-12-07
請看下面的例子:// 例子1 function test_global() { global $var1, $var2; $var2 =& $var1; } function test_globals() { $GLOBALS['var3'] =& $GLOBALS['var1']; } $var1 = 5; $var2 = $var3 = 0; test_global(); print $var2 ."\n"; test_globals();
Time of Update: 2018-12-07
單例模式顧名思義,就是只有一個執行個體。由此借鑒之,在資料庫操作中,對於同一個庫只允許一個執行個體存在很重要.Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?phpclass mysql{ protected $db; static private $instance = null; /** * 得到資料庫連接
Time of Update: 2018-12-07
PHP的session功能,一直為許多的初學者為難。就連有些老手,有時都被搞得莫名其妙。本文,將這些問題,做一個簡單的匯總,以便大家查閱。 來自 http://blog.csdn.net/feel8/archive/2004/10/29/159032.aspx 1. 錯誤提示 Warning: Cannot send session cookie - headers already sent Warning: Cannot send session cache
Time of Update: 2018-12-07
<?php function encode_pass($tex,$key,$type="encode",$expiry=0){ $chrArr=array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J','K',
Time of Update: 2018-12-07
sudo apt-get install apache2sudo apt-get install php5sudo apt-get install libapache2-mod-php5sudo apt-get install php5-curl #安裝curl庫用於通訊cd /etc/apache2sudo vi ports.conf#增加下面2行(不含#號和空格)# NameVirtualHost *:7000# Listen 7000cd
Time of Update: 2018-12-07
function pageFactory($path,$layout){ $factorys = Array ("template/1.html"=>TemplatePage1); return new $factorys[$layout]($path,$layout);}class Page{ public $path = null; public $layout = ""; public $data = Array(); public
Time of Update: 2018-12-07
目前網路上好多網站的新聞發布系統都採用了動態伺服器技術產生靜態HTML的做法,這樣做的好處是:一是能減輕其伺服器的負擔,二是因為產生了HTML靜態頁面,所以其網站被搜尋引擎搜尋到的機率更大一些。筆者的網站曾經使用PHP這 一動態技術來構建新聞發布系統,其原理也就是應用了PHP產生HTML靜態頁面的技術,相關平台是 Windows XP
Time of Update: 2018-12-07
請注意使用writeImages()而不是writeImage() 1 <?php 2 try 3 { 4 // Read in the animated gif 5 $animation = new Imagick("animation.gif"); 6 7 // Loop through the frames 8 foreach ($animation as $frame) 9 {10 // Thumbnail
Time of Update: 2018-12-07
<?php/** * php二分尋找法 */ $arr = array(0,4,5,6,7,8,9);function search($arr, $low,$high,$k){ if($high >= $low){ $middle = intval(($high+$low)/2); //ceil 和intval 無差別 if($arr[$middle] == $k){ return '找到'; }elseif ($
Time of Update: 2018-12-07
由於是午休時間寫的 所以不太詳細盡情諒解。 主要還是老生常談的問題 OOP 。。。 工作兩年 對OOP 這玩意有些自己的理念 ,但翻遍了各大書店的OOP 介紹都是天馬行空 (很像是一個人寫的) <?php class Car{ public getName(){ return $this->name; } public getSpeed(){ return
Time of Update: 2018-12-07
<?phpInterface Obseverr{ public function update(Obseverable $subject);}abstract class Obsever implements Obseverr{ protected $date; public function update(Obseverable $date){ $this->date = $date; }}abstract class Obseverable{
Time of Update: 2018-12-07
<?php/** * php 快速排序 */$arr = array(7,8,6,5,3,10);function quick($array){ if(count($array) <=1) return $array; $k = $array[0]; $left = array(); $right = array(); for($i =1; $i< count($array); $i++){
Time of Update: 2018-12-07
1-簡單原廠模式不熟悉物件導向的朋友,建議先看看用星際快速入門PHP物件導向編程上次用星際爭霸討論了物件導向的基礎知識,似乎物件導向能解決很多問題。但是還會有很多問題,簡單的靠類和對象解決不得太好。比如如何根據玩家輸入的內容(儘管可以轉化為其他字串),來確定要製造的兵種,玩家不會輸入代碼:new Marine()。