Time of Update: 2016-07-25
相對路徑轉化成絕對路徑 //相對路徑轉化成絕對路徑 function relative_to_absolute($content, $feed_url) { preg_match('/(http|https|ftp):///', $feed_url, $protocol); $server_url =
Time of Update: 2016-07-25
package ims.common.util; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import
Time of Update: 2016-07-25
將HTML表格的每行每列轉為數組,採集表格式資料 //將HTML表格的每行每列轉為數組,採集表格式資料 function get_td_array($table) { $table = preg_replace("']*?>'si","",$table);//OSPHP.COm.CN$table = preg_replace("']*?>'si","",$table);
Time of Update: 2016-07-25
《Web 2.0 開發實戰》一書的作者,Quentin Zervaas 在書中提到的一個簡易PHPData Access Objects。 /** * DatabaseObject * * Abstract class used to easily manipulate data in a database table * via
Time of Update: 2016-07-25
把全形數字轉為半形數字 //把全形數字轉為半形數字 function GetAlabNum($fnum){ $nums = array("0","1","2","3","4","5","6","7","8","9");//OSPHP.com.CN$fnums = "0123456789"; for($i=0;$i$fnum = ereg_replace(
Time of Update: 2016-07-25
擷取訪問者作業系統 function osinfo() { $os=""; $Agent = $GLOBALS["HTTP_USER_AGENT"]; if (eregi('win',$Agent) && strpos($Agent, '95')) { //OsPHP.COM.CN $os="Windows 95"; } elseif (eregi('win 9x',$
Time of Update: 2016-07-25
php產生excel文檔 header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=test.xls"); echo "test1t"; echo "test2tn"; echo "test1t"; echo "test2tn"; echo "test1t"
Time of Update: 2016-07-25
$post_content = "@oschina和@twitter在研究用#PHP#的#Regex#過濾話題和對象名";$tag_pattern = "/\#([^\#|.]+)\#/";preg_match_all($tag_pattern, $post_content, $tagsarr);$tags = implode(',',$tagsarr[1]);$user_pattern = "/\@([a-zA-z0-9_]+)/";$post_content = preg_replace($
Time of Update: 2016-07-25
這是我的MVC架構ActionController的封裝 /* * MST_Library v3.1 * @autohr Janpoem */if (!defined('IN_MST_CORE'))exit('MST_ActionController Can\'t be include single!');if (!defined(MST_Core::LITE_MODE)
Time of Update: 2016-07-25
delete.php$link=mysql_connect("localhost","root",""); mysql_select_db("dbname"); $id=$_POST['select']; //調用input的nameforeach($id as $ide){ $exec="delete from tablename where sID=$ide"; $result=mysql_query($exec); if((mysql_affected_rows()==0) or
Time of Update: 2016-07-25
支援對漢字進行切割,不會出現?之類的半個漢字 //漢字字元切割,可以防止出現半個漢字的情況function substr_cut($title,$length=8){if (strlen($title)>$length) {$temp = 0;for($i=0; $iif (ord($title[$i]) >128) $temp++;if ($temp%2 ==
Time of Update: 2016-07-25
利用open flash chart組建圖表 訪問方式: http://127.0.0.1/chart/chart.html?ofc=data.php
Time of Update: 2016-07-25
zendframework 配置執行個體
Time of Update: 2016-07-25
define('CACHE_ROOT', dirname(__FILE__).'/cache'); //緩衝存放目錄 define('CACHE_TIME', 1800);//緩衝時間 單位秒 define('CACHE_FIX','.html'); $CacheName=md5($_SERVER['REQUEST_URI']).CACHE_FIX; //快取檔案名 $CacheDir=CACHE_ROOT.'/'.substr($CacheName,0,1);/
Time of Update: 2016-07-25
這貨是從 Martin 大神的《公司專屬應用程式架構模式》中學到的,輔助 PHP 動態語言的特性,可以比 Java 輕鬆很多的實現消極式載入(LazyLoad)。基本原理是通過一個虛代理(Virtual Proxy)做預留位置,一旦訪問代理對象的某成員(方法或屬性),載入就被觸發。 不過我實現的這個版本有局限性: 只適用於對象,無法代理數組等基礎資料型別 (Elementary Data Type)(需要用 ArrayObject 一類的內建對象封裝)
Time of Update: 2016-07-25
將資料庫取的分類資料格式化,如: 新聞 --體育新聞 --娛樂新聞 財經 --外匯 --金融 class tree{ /**未經處理資料*/public $original; /**id的鍵名*/ public $id; /**父id的鍵名*/
Time of Update: 2016-07-25
話說深圳 2011 的大運會不是要來啦嘛,於是深大要開發一個志願者服務站,我被團委抓去服役了。過程中寫了一個小小的表單工具包。驗證功能不是我自己實現的,依賴 Kohana_Validate(Kohana V3.0x 分支)。但是自己就按照 《J2EE 噁心模式》所說,弄了個同步令牌,防止重複提交表單。這個組件也設定了抽象層,我覺得可以把驗證碼也作為一個令牌子類整合。但是現在沒時間弄,先把代碼分享上來等被拍磚啦~
Time of Update: 2016-07-25
準系統: 1、實現學生基本資料的維護(增刪改); 2、實現課程資訊的維護(增刪改); 3、實現選課的管理(選課、退課); 4、實現成績管理(錄入)、統計學生和課程平均成績 $conn=mysql_connect("localhost","root","123456") or die('串連失敗');//串連伺服器mysql_
Time of Update: 2016-07-25
mysql以檔案形式匯入匯出整個資料庫 //使用時一定要注意是否是處於匯入狀態,如果是匯入操作,一定要先備份資料庫,否則資料會被清空。。/* 匯出SELECT * INTO OUTFILE 'c:/name.txt'FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\''LINES TERMINATED BY
Time of Update: 2016-07-25
/** 擷取機器網卡的物理(MAC)地址 **/ class GetMacAddr { var $return_array = array(); // 返回帶有MAC地址的字串數組 var $mac_addr; function GetMacAddr($os_type)