Time of Update: 2016-07-25
encode64可以獲得最短的由26個英文大小寫字母數字加上"-_"兩個符號編碼的資料, 這個個字串可以在網路自由傳輸, 無需考慮被自動轉碼引起的混亂. 缺點: 對於大字串太慢了, 原因不明, 可能PHP指令碼本身就是慢, 所以它內建 很多函數, 這些函數如果用指令碼來實現是不可忍受的. 而JavaScript就沒這個問題, 指令碼的速度快的多. //encode64編碼可以同時取代encodeURI,encodeURIComponent,endode函數,
Time of Update: 2016-07-25
驗證手機號碼 function isMobile(phone){ // 根據號碼段的不同和首碼不同可適當修改 var reValue = /^(0|86|17951)?(13[0-9]|15[012356789]|18[0-9]|14[57]|17[0-9])[0-9]{8}$/; if(!reValue.test(phone)){ return false; }else{ return true; }} 複製代碼 驗證郵箱 function
Time of Update: 2016-07-25
define('HOST_FILE', 'C:\Windows\System32\drivers\etc\hosts'); $hm = new HostManage(HOST_FILE); $env = $argv[1]; if (empty($env)) { $hm->delAllGroup(); } else { $hm->addGroup($env); }
Time of Update: 2016-07-25
date_default_timezone_set("Asia/Calcutta");function dt_differ($start, $end){ $start = date("G:i:s:m:d:Y", strtotime($start)); $date1=explode(":", $start); $end = date("G:i:s:m:d:Y", strtotime($end)); $date2=explode(":", $end); $starttime =
Time of Update: 2016-07-25
//單檔案上傳函數的封裝//檔案上傳原理:將用戶端的檔案上傳到伺服器端,再將伺服器端的臨時檔案移動到指定目錄即可。//檔案的方向:用戶端——>伺服器(臨時檔案)——>指定目錄,當檔案進入伺服器時它就是臨時檔案了,這時操作中要用臨時檔案的名稱tmp_name。//在用戶端設定上傳檔案的限制(檔案類型和大小)是不安全的,因為客戶能通過原始碼修改限制,所以在服務端這裡設定限制。//設定編碼為UTF-8,以避免中文亂碼
Time of Update: 2016-07-25
class GeoHelper{ /** * @param int $lat1 * @param int $lon1 * @param int $lat2 * @param int $lon2 * @param string $unit * @return */ public static function distance($lat1, $lon1, $lat2, $lon2, $unit = "K") {
Time of Update: 2016-07-25
/* * memcache隊列類 * 支援多進程並發寫入、讀取 * 邊寫邊讀,AB面輪值替換 * @author guoyu * @create on 9:25 2014-9-28 * @qq技術行業交流群:136112330 * * @example: * $obj = new memcacheQueue('duilie'); * $obj->add('1asdf');
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
//代碼也可以用於統計目錄數//格式化輸出目錄大小 單位:Bytes,KB,MB,GB function getDirectorySize($path){ $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' . $
Time of Update: 2016-07-25
在php環境運行上面的代碼,大家就可以看到瀏覽器詢問使用者是否下載excel文檔,點擊儲存,硬碟上就多了一個excel的檔案,使用excel開啟就會看到最終的結果,怎麼樣不錯吧。 其實在做真正的應用的時候,大家可以將資料從資料庫中取出,然後按照每一列資料結束後加\t,每一行資料結束後加\n的方法echo出來,在php的開 頭用header("Content-type:application/vnd.ms-excel");表示輸出的是excel檔案,用
Time of Update: 2016-07-25
$DB_Server = "localhost";$DB_Username = "mydowns";$DB_Password = "";$DB_DBName = "mydowns";$DB_TBLName = "user";$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password)or die("Couldn@#t connect.");$Db = @mysql_select_db($DB_DBName, $Connect)
Time of Update: 2016-07-25
class FileUpload {private $filepath; //指定上傳檔案儲存的路徑private $allowtype=array('gif', 'jpg', 'png', 'jpeg'); //充許上傳檔案的類型private $maxsize=1000000; //允上傳檔案的最大長度 1Mprivate $israndname=true; //是否隨機重新命名, false不隨機,使用原檔案名稱private $originName; //源檔案名稱private
Time of Update: 2016-07-25
define('EARTH_RADIUS', 6370.6935); function vicinity($lng, $lat, $distance = 0.5) { //$distance = 0.5; // 單位 10KM $radius = EARTH_RADIUS; $dlng = rad2deg(2*asin(sin($distance/(2*$radius))/cos($lat))); $dlat =
Time of Update: 2016-07-25
//非遞迴擷取所有後代分類function get_offspring($pids, $list){ $npid = array(); $offspring = array(); $has_child = true; while($has_child) { $has_child = false; foreach($list as $lk => $lv) { if(in_array($lv['pid'],
Time of Update: 2016-07-25
//人民幣金額轉大寫程式PHP版class Ext_Num2Cny{ static $basical = array(0=>"零","壹","貳","三","肆","伍","陸","柒","捌","玖"); static $advanced=array(1=>"拾","佰","仟"); public static function ParseNumber($number){ $number=trim($number); if ($number>999999999999)
Time of Update: 2016-07-25
class ValidationCode { //屬性 private $width; private $height; private $codeNum; private $image; private $disturbColorNum; //幹擾元素數目 private $checkCode; function
Time of Update: 2016-07-25
joomla組件是一款可以輕鬆將Joomla的文章同步到,如果你的公眾號是訂閱號的話,可以設定每天自動推送,目前只支援joomla的核心文章組件。我們正在研發能支援k2,zoo的版本。joomla組件免費使用,有需求的請到“joomla中國”或“ZMAX程式人”來瞭解。joomla同步群組件近期更新:新增了多語言的支援
Time of Update: 2016-07-25
function GrabImage($url,$filename="") { if($url=="") return false; if($filename=="") { $ext=strrchr($url,"."); if($ext!=".gif" && $ext!=".jpg") return false; $filename=date("dMYHis").$ext; } ob_start();
Time of Update: 2016-07-25
$error = ""; //error holder if(isset($_POST['createpdf'])){ $post = $_POST; $file_folder = "files/"; // folder to load files if(extension_loaded('zip')){ // Checking ZIP extension is available
Time of Update: 2016-07-25
php圖片轉換成ASCII碼,轉換後可以直接通過字串顯示圖片 Ascii $image = 'image.jpg'; // Supports http if allow_url_fopen is enabled $image = file_get_contents($image); $img = imagecreatefromstring($image);