Time of Update: 2016-07-25
PHP ZipArchive 是PHP內建的擴充類,可以輕鬆實現ZIP檔案的壓縮和解壓,使用前首先要確保PHP ZIP 擴充已經開啟。 /* 說明: 將多個檔案壓縮成一個zip檔案的函數 * @param $files 數群組類型 * @param destination 目標檔案的路徑 * @param $overwrite 是否為覆蓋與目標檔案相同的檔案 */function create_zip($files = array(),$destination
Time of Update: 2016-07-25
/** * “抽獎”函數 * * @param integer $first 起始編號 * @param integer $last 結束編號 * @param integer $total 獲獎人數 * * @return string **/function isWinner($first, $last, $total){ $winner = array(); for ($i=0;;$i++) { $number =
Time of Update: 2016-07-25
php不破壞單詞截取子字串 /* snippet(phrase,[max length],[phrase tail]) snippetgreedy(phrase,[max length before next space],[phrase tail]) */ function snippet($text,$length=64,$tail="...") { $text = trim($text); $txtl = strlen($text);
Time of Update: 2016-07-25
實現php檔案安全下載! public function downloads($name){ $name_tmp = explode("_",$name); $type = $name_tmp[0]; $file_time = explode(".",$name_tmp[3]); $file_time = $file_time[0]; $file_date = date("Y/md",$file_time);
Time of Update: 2016-07-25
這個php圖片上傳類功能非常完善,完全可以滿足各種圖片上傳需求 /************************************** seesaw associates | http://seesaw.net client: file: description: Copyright (C) 2008 Matt Kenefick(.com)**************************************/ class mk_imageUpload{
Time of Update: 2016-07-25
function qsort(&$arr){ _quick_sort($arr, 0, count($arr) - 1);} /** * 採用遞迴演算法的快速排序。 * * @param array $arr 要排序的數組 * @param int $low 最低的排序子段 * @param int $high 最高的排序欄位 */function _quick_sort(&$arr, $low, $high){ $low_data = $arr[$low];
Time of Update: 2016-07-25
php計算兩個座標(經度,緯度)之間的距離,返回結果為米或者千米 function distance($lat1, $lng1, $lat2, $lng2, $miles = true){ $pi80 = M_PI / 180; $lat1 *= $pi80; $lng1 *= $pi80; $lat2 *= $pi80; $lng2 *= $pi80; $r = 6372.797; // mean radius of Earth in km
Time of Update: 2016-07-25
/*untested*/ class database_mssql { var $database = NULL;var $sqls = NULL; var $host = NULL;var $username = NULL;var $password = NULL;var $databaseName = NULL;var $link = NULL;var $queries = NULL;var $errors = NULL; function database_mssql($host,
Time of Update: 2016-07-23
// 設定資料庫 define('DB_HOST', '127.0.0.1'); //伺服器位址 define('DB_USER', 'root'); //使用者名稱 define('DB_PASS', ''); //密碼 define('DB_DATABASENAME', 'fenxiao'); //資料庫 class Dbmysql { /* *變數 **/ private $tablename=""; //表名 private $fieldname="*";
Time of Update: 2016-07-25
/** * 驗證類 * * @lastmodify 2014-5-16 * @author jy625 */ class VerifyAction{ /** * 是否為空白值 */ public static function isEmpty($str){ $str = trim($str);
Time of Update: 2016-07-25
PHP目錄的遍曆 //php目錄的遍曆function showDetail($dirname){$ds = opendir($dirname);while($file = readdir($ds)){$path = $dirname."/".$file;if($file != "." && $file != ".."){ //這裡是個坑if(is_dir($path)){showDetail($path);
Time of Update: 2016-07-25
class httpClient { public $buffer = null; // buffer 擷取返回的字串 public $referer = null; // referer 設定 HTTP_REFERER 的網址 public $response = null; // response 伺服器響應的 header 資訊 public $request = null; // request 發送到伺服器的
Time of Update: 2016-07-23
// local file that should be send to the client$local_file = 'test-file.zip';// filename that the user gets as default$download_file = 'your-download-name.zip'; // set the download rate limit (=> 20,5 kb/s)$download_rate = 20.5;
Time of Update: 2016-07-23
使用新浪IP庫擷取IP詳細地址class Tool{ /** * 擷取IP的歸屬地( 新浪IP庫 ) * * @param $ip String IP地址:112.65.102.16 * @return Array */ static public function getIpCity($ip) { $ip =
Time of Update: 2016-07-23
如果你稍微研究下laravel登入的話,能找到這段代碼public function loginUsername(){ return property_exists($this, 'username') ? $this->username : 'email';}複製代碼這裡做了判斷 是否存在屬性username 沒有及用email.所以想用使用者名稱登入的話,就直接改下AuthController.php 增加個username的屬性就OK了。protected $username = '
Time of Update: 2016-07-25
/** +------------------------------------------------ * 通用的樹型類 +------------------------------------------------ * @author yangyunzhou@foxmail.com +------------------------------------------------ * @date 2010年11月23日10:09:31 +------------------------
Time of Update: 2016-07-25
圖片處理函數功能:縮放、剪下、相框、浮水印、銳利化、旋轉、翻轉、透明度、反色,處理並儲存記錄的思路:當有圖片有改動時自動產生一張新圖片,命 名方式可以考慮在原圖片的基礎上加上步驟,例如:圖片名稱+__第幾步。 在一些需要圖片進階處理功能的Web應用中,可以參考這個類。 /*圖片處理函數功能:縮放、剪下、相框、浮水印、銳利化、旋轉、翻轉、透明度、反色處理並儲存記錄的思路:當有圖片有改動時自動產生一張新圖片,命名方式可以考慮在原圖片的基礎上加上步驟,例如:圖片名稱+__第幾步*/class
Time of Update: 2016-07-23
這是一篇以 iOS 開發人員的視角寫給廣大iOS 程式猿的 PHP 入門指南.在這篇文章裡我努力去發掘 objectiv-c 與 php 之間的共性,來協助有一定 iOS
Time of Update: 2016-07-25
class Page { private $total; //資料表中總記錄數 private $listRows; //每頁顯示行數 private $limit; private $uri; private $pageNum; //頁數 private $config=array('header'=>"個記錄", "prev"=>"上一頁", "next"=>"下一頁", "first"=>"首 頁",
Time of Update: 2016-07-25
很多時候我們需要對資料進行加密解密,比如有些資料需要儲存到cookie中,但又不能被使用者輕易得到這些資料,這時我們就需要加密這些資料儲存到cookie中,等我們需要使用它們的時候再解密。 // 加密資料並寫到cookie裡$cookie_data = $this -> encrypt("nowamagic", $data); $cookie = array( 'name' => '$data', 'value' => $cookie_data,