Time of Update: 2016-07-25
使用php實現檔案強制下載,多會用到header函數。 例子,php檔案下載執行個體。 class Downfile {function downserver($file_name){$file_path = "./img/".$file_name;//轉碼,檔案名稱轉為gb2312解決中文亂碼$file_name = iconv("utf-8","gb2312",$file_name);$file_path = iconv("utf-8","gb2312",$file_path);$fp =
Time of Update: 2016-07-25
php GeoIP庫使用教程什麼是GepIP ? 所謂GeoIP,就是通過來訪者的IP, 定位他的經緯度,省/地區,省市,甚至街道等位置資訊。這裡面的技術不算難題,關鍵在於有個精準 的資料庫。有了準確的資料來源就奇貨可居賺點小錢,可是發揚合作精神,集體貢獻眾人享用是我們追求的。GeoIP如何使用? 首先我們需要資料資訊,所以先擷取一個免費的資料庫:GeoIP.dat.gz ,接著解壓得到:GeoIP.dat, 然後就是對資料檔案的按需操作,這邊範例使用的是PHP。 GeoIP +
Time of Update: 2016-07-25
error_reporting在php編程中的使用頻度,想必大家是非常清楚的了,本文介紹error_reporting的用法,供大家學習參考。如果參數 level 未指定,當前報錯層級將被返回。下面幾項是 level 可能的值:1 E_ERROR2 E_WARNING4 E_PARSE8 E_NOTICE16 E_CORE_ERROR32 E_CORE_WARNING64 E_COMPILE_
Time of Update: 2016-07-25
最近我們公司信易網路在用yii開發一個項目自己臨時學習了一下yii 把學習感悟和大家一起分享一下Yii Framework是一個基於組件、用於開發大型 Web 應用程式的高效能 PHP 架構。Yii提供了今日Web 2.0應用開發所需要的幾乎一切功能。Yii是最有效率的PHP架構之一在剛學習yii 的時候就感覺這個組件特別難學,好多東西我都搞不懂比如什麼widget 一看到這個我就頭大,但真是因為他是物件導向的所以我還是堅持了下來,後來逐步逐步查資料在百度裡面搜尋,明白了許多正是因為yii
Time of Update: 2016-07-25
Guzzle是一個PHP HTTP 用戶端和架構,用於構建 RESTful web service 用戶端。All the power of cURL with a simple interface.持久串連和並行請求Streams request and response bodiesService descriptions for quickly building clients.Powered by the Symfony2 EventDispatcher.Use all of the
Time of Update: 2016-07-25
雖然我是個PHP新手,但是今天看到一段代碼,忍不住修改了幾行。 class runTime { var $StartTime = 0; var $StopTime = 0; var $TimeSpent = 0; function start(){ $this->StartTime = microtime(); } function stop(){ $this->StopTime = microtime(); }
Time of Update: 2016-07-25
大家平常見的最多的是php串連mysql的類,今天給大家分享一個php串連sql server的類。感興趣的朋友可以參考下。class DB_Handle { var $ClassName = "DB_Handle"; var $Server; var $UserName; var $Password; var $Database; var $LinkID = 0; var $QueryResult = ""; var $LastInsertID
Time of Update: 2016-07-25
說明:使用curl 能快捷的抓取網頁、類比POST、GET請求,當然也不僅僅是HTTP協議的一些封裝,還支援FTP、代理、HTTPS、LDAP等應用。 curl並不是PHP特有的,很多語言中都有,一個東西好用,自然就會被推廣開,就像很多年前的log4j一樣的道理,剛開始是JAVA版本,隨後也出現log4c,log4c++??curl 也是一樣的道理。curl 並非PHP預設支援,需要在配置裡開啟此項的載入extension= php_curl.dll 在linux
Time of Update: 2016-07-25
php實現對文本資料庫的資料顯示、加入、修改、刪除、查詢五大基本操作的方法 此文本資料庫共有欄位9個: private $bankid; //銀行ID private $bankname; //銀行名稱 private $bankimg; //銀行圖片 private $bankarea; //覆蓋地區 private $bankcard; //受理卡種 private $banklimit; //支付限額 private $bankpasswd; /
Time of Update: 2016-07-25
例子,php擷取上周,本周,上月,本月,本季度,上季度。 date_default_timezone_set('PRC'); date("Y-m-d H:i:s", strtotime(" +2 year")); date("Y-m-d H:i:s", strtotime(" +2 month")); date("Y-m-d H:i:s", strtotime(" +2 week")); date("Y-m-d H:i:s", strtotime(" +2 day")); date("
Time of Update: 2016-07-25
5.30以上的版本才能使用,繼承了上一版本的快速重新導向的特點(單獨類,全部使用靜態調用),增添了一個很重要的功能和屬性,可以調用其他url中的模組了,也使得模組與模組間或頁面與頁面間的函數簡化共用得以實現。.htaccess檔案寫法: #-------------- .htaccess start ---------------RewriteEngine onRewriteRule !.(js|ico|gif|jpg|png|css|swf|htm|txt)$
Time of Update: 2016-07-25
遍曆某檔案夾下的所有檔案和檔案夾 function list_dir($dirpath){ if($dirpath[strlen($dirpath)-1]!="\\"){$dirpath.="\\";} static $result_array=array(); if(is_dir($dirpath)){
Time of Update: 2016-07-25
例子,php擷取使用者IP地址。 // 111111111111 echo $_SERVER['REMOTE_ADDR']; // 2222222222222 function get_local_ip() { $preg = "/\A((([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\.){3}(([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\Z/";
Time of Update: 2016-07-25
一個可擴充的php驗證類,類裡面可以的各類驗證可自行調整實現,現在為基本實現方式。需要添加規則的話, 直接定義方法,方法名即為規則名稱。具體參考使用方法。 require_once('./Validator.class.php');$data = array( 'nickname' => 'heno' , 'realname' =>
Time of Update: 2016-07-25
詳細樣本地址:http://www.alleyloft.com/contents/share?id=3 /*********************************************** *
Time of Update: 2016-07-25
/* $cache = new Cache("../cache/",20); // 建構函式,建立緩衝類對象$cache->PutCache(); // 倒出緩衝*/class Cache{private $CacheDir = ’Cache’; /* 緩衝目錄 */private $SetTimeOut = 10; /* 緩衝到期時間 */private $SetExt = ’.cache’; /* 快取檔案尾碼名 */private $CacheFileUrl = ’’; /*
Time of Update: 2016-07-25
[production]; logsresources.log.stream.writerName = "Stream"resources.log.stream.writerParams.stream = APPLICATION_PATH "/../data/logs/production.log"resources.log.stream.writerParams.mode = "a"; sessionsresources.session.save_path =
Time of Update: 2016-07-25
//第一步 建立解析器 xml_parser_create(編碼);$xml = xml_parser_create('utf-8');//xml_parser_set_option — 為指定 XML 解析進行選項設定//xml_parser_set_option($xml,XML_OPTION_CASE_FOLDING,false);
Time of Update: 2016-07-25
RewriteEngine onRewriteRule !\.(js|ico|gif|jpg|png|css)$ index.phpphp_value include_path "../lib"#------------------------------httpd.confRewriteEngine onRewriteLog "g:\ZendFramework-0.1.2\rewrite.log"RewriteRule !\.(js|ico|gif|jpg|png|css|php)$
Time of Update: 2016-07-25
public function fooAction(){ // forward to another action in the current controller and module: $this->_forward('bar', null, null, array('baz' => 'bogus'));}public function barAction(){ // forward to an action in another controller,