Time of Update: 2016-06-13
PHP中如何?Singleton(單例模式) 單例模式有以下的特點:?單例類只能有一個執行個體。 單例類必須自己建立自己的唯一的執行個體。 單例類必須給所有其他對象提供這一執行個體。代碼: Singleton.php:class Singleton{??? private static $instance; ??? private function __construct()??? {??? } ??? public static function getInstance()?
Time of Update: 2016-06-13
PHP實現二叉樹,線索二叉樹 createThreadTree(); echo $tree->threadList() . "\n";從第一個結點開始遍曆線索二叉樹 echo $tree->threadListReserv();從最後一個結點開始反向遍曆?>biTree.phpdata = $data; } //我不喜歡使用魔術方法 public function getData(){
Time of Update: 2016-06-13
求php上傳檔案夾代碼........上傳一個檔案夾 並在伺服器上保持這個檔案夾的目錄結構,並把其中的檔案上傳上去,求思路,求方法,謝謝------解決方案--------------------讀結構,伺服器上mkdir------解決方案--------------------PHP做伺服器沒問題,問題在於,你不能使用瀏覽器做用戶端(至少不能是常規瀏覽器),因為目前好像還沒有哪家瀏覽器提供直接讀目錄的API。------解決方案--------------------瀏覽器讀不了檔案夾的吧。
Time of Update: 2016-06-13
PHP Header 緩衝 --- Header 參數說明 1. Accept:告訴WEB伺服器自己接受什麼介質類型,*/* 表示任何類型,type/* 表示該類型下的所有子類型,type/sub-type。2. Accept-Charset:?? 瀏覽器申明自己接收的字元集Accept-Encoding:
Time of Update: 2016-06-13
PHP輸出日曆 PHP實現日曆效果 日一二三四五六";for($i=0;$i"; for($k=0;$k$mdays+$wk1st-1) ? $dayecho=" " : $dayecho=$tabidx-$wk1st+1; //突出標明今日日期 // $dayecho="$dayecho"; if($dayecho==$datenow){$todaybg = " class=current";} else{$todaybg = "";}
Time of Update: 2016-06-13
php中的proc_open+fwrite應用問題我想在php用proc_open調用一個c++寫的exe程式,由於裡面有要求輸入參數所以我用fwrite寫入終端,php代碼如下PHP code array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 =
Time of Update: 2016-06-13
php include 和io流的效率 之前看了,平凡的世界大大的一篇文章 傳送門 ,php檔案快取效能測試。很不以為然,include怎麼會比io流慢了 ,就算加上序列化,按照常理,include也會稍快一些,但是事實卻是是如此! 代碼如下測試io流+序列化function read_cache($filename) {??????? if($datas = file_get_contents($filename)){??????????? return $datas;??????? }
Time of Update: 2016-06-13
PHP HMVC架構kohana 小結1 之前kohana 3的安裝見:http://jackyrong.iteye.com/admin/blogs/11860061 在bootstrap中設定開發模式: Kohana::$environment = Kohana::DEVELOPMENT; 再增加如下代碼: if (isset($_SERVER['KOHANA_ENV'])){Kohana::$environment =
Time of Update: 2016-06-13
php數組和字串的相互轉換,資料結構不變 一個描述 PHP 資料的函數。傳回值是一個字串。有的時候為了把一些資料轉為字串存起來,但是希望保持資料原來有結構和內容。就要用到這個函數。$a=array('data'=>"hi", 123);$b=serialize($a);//對數組進行序列化echo $b;? //這個就是描述過的數組但在這裡是一個字串而已$c=unserialize($b); //把描述過的資料恢複(還原序列化)print_r($c);?? //還原成為 $a
Time of Update: 2016-06-13
(轉)Log4php使用及配置指南
Time of Update: 2016-06-13
php 運算元組 (合并,拆分,追加,尋找,刪除等) 1. 合并數組array_merge()函數將數組合并到一起,返回一個聯合的數組。所得到的數組以第一個輸入數組參數開始,按後面數組參數出現的順序依次迫加。其形式為:array array_merge (array array1
Time of Update: 2016-06-13
nginx伺服器下訪問不存在的php頁面No input file specified. 在nginx/conf/nginx.conf 找到:fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 改為:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;http://apps.hi.baidu.com/share/detail/31677
Time of Update: 2016-06-13
php 儲存遠程圖片到本地 第一種: 精確型 ' : "false"; 第二種:從文章中提取圖片,並儲存至本地 function getImg($str){ $str = stripslashes($str); $pattern = "/]*src\=\"(([^>]*)(jpg|gif|png|bmp|jpeg))\"/i"; //擷取所有圖片標籤的全部資訊 preg_match_all($pattern,
Time of Update: 2016-06-13
PHP反射API 反射是什嗎?它是指在PHP運行狀態中,擴充分析PHP程式,匯出或提取出關於類、方法、屬性、參數等的詳細資料,包括注釋。這種動態擷取的資訊以及動態調用對象的方法的功能稱為反射API。反射API概覽:class Reflection { }interface Reflector { }class ReflectionException extends Exception { }class ReflectionFunction implements Reflector {
Time of Update: 2016-06-13
php學習總結-date 在用PHP5.3以上的PHP版本時,只要是涉及時間的會報一個錯誤echo date("D")."******";?>輸出如下"PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the
Time of Update: 2016-06-13
php 中文轉拼音函數 剛在部落格園發現一個很好用的函數,可以將中文轉成拼音,轉載一下160) { $_Q = ord(substr($_String, ++$i, 1)); $_P = $_P*256 + $_Q - 65536; } $_Res .= _Pinyin($_P, $_Data); } return preg_replace("/[^
Time of Update: 2016-06-13
php基礎知識(4)-cookie使用
Time of Update: 2016-06-13
內部用Drupal/PHP開發規範1.2
Time of Update: 2016-06-13
PHP魔術函數執行時間和順序解析 一:魔術函數1。__construct() 執行個體化對象時被調用, 當__construct和以類名為函數名的函數同時存在時,__construct將被調用,另一個不被調用。 2。__destruct() 當刪除一個對象或對象操作終止時被調用。 3。__call() 對象調用某個方法, 若方法存在,則直接調用; 若不存在,則會去調用__call函數。 4。__get() 讀取一個對象的屬性時, 若屬性存在,則直接返回屬性值;
Time of Update: 2016-06-13
PHP上傳檔案 if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/pjpeg"))&& ($_FILES["file"]["size"] ? {? if ($_FILES["file"]["error"] > 0)??? {??? echo "Return Code: " .