Time of Update: 2016-07-25
有時希望當點擊對應連結時直接下載,而不是在網頁上顯示,那麼就需要強制設定header頭資訊。分享一段不會產生亂碼的php函數實現代碼,實現檔案的強制下載。例子,php實現檔案強制下載的代碼。 /** * Downloader * * @param $archivo * path al archivo * @param $downloadfilename * (null|string) el nombre que queres usar para el archivo que se va a
Time of Update: 2016-07-25
1.判斷某一天是星期幾/** * 判斷某一天是星期幾 * @param $date 格式'YYYY-mm-dd' 格式出錯返回false,正確返回對應日期中星期一到星期天的某一天 */function get_weekday($date){$date_arr = explode('-', trim($date));if(!checkdate(intval($date_arr[1]), intval($date_arr[2]), intval($date_arr[0]))){return
Time of Update: 2016-07-25
Action代碼: public function index(){$prod = I("get.prod_en");$id = I("get.id", 0, "int");if ($prod == ""){$serviceProduct = array();//多重迴圈遍曆的數組複製代碼//資料儲存在兩張表中,這裡通過迴圈初始化$serviceProduct數組$service = M("product_class")->order("oid ASC")->select();for ($
Time of Update: 2016-07-25
/*==================================================================*/ /* 檔案名稱:BaseLogic.class.php */ /* 概要: 資料處理公用類. */ class BaseLogic extends MyDB {
Time of Update: 2016-07-25
Xcache簡介 前面已經介紹了PHP加速器的原理和功用(參見LAMP架構之PHP-FPM 伺服器),xcache作為目前使用廣泛的PHP加速器之一,其效能比早期的eAccelerator加速器要優良,故本次就對比一下PHP程式在執行時加速器xcache對其的效能影響。 安裝xcache 複製代碼# 安裝tar xf xcache-3.0.3.tar.gzcd xcache-3.0.3/usr/local/php/bin/phpize #
Time of Update: 2016-07-25
學習php通過字串調用函數。1. call_user_funcfunction a($b,$c){ echo $b; echo $c;}call_user_func('a', "111","222");call_user_func('a', "333","444");//顯示 111 222 333 444?>複製代碼 調用類內部的方法比較奇怪,居然用的是array,不知道開發人員是如何考慮的,當然省去了new,也是滿有新意的:class a { function b($c){
Time of Update: 2016-07-25
看下uchome中定時計劃任務的設定方法:1,把所有的計劃任務存放到資料庫2,每次使用者進行操作或開啟頁面的時候都按排序執行一條計劃任務. 也就是輪番判斷,時間到了的, 就在使用者進程中執行.uchome的計劃任務代碼在
Time of Update: 2016-07-25
1,無法傳遞變數 get,post,session在最新的php 版本中自動全域變數是關閉的,所以要從上一面取得提交過來得變數要使用$_get[’foo’],$_post[’foo’],$_session[’foo’]來得到。當然也可以修改自動全域變數為開(php .ini改為register_globals = on);考慮到相容性,還是強迫自己熟悉新的寫法比較好。2,win下apache 用get方法傳遞中文參數會出錯: test.php ?a=你好&b=你也好
Time of Update: 2016-07-25
uxf 是個 php 架構,基於discuz! X3.0以上環境運行。
Time of Update: 2016-07-25
例子,檢測php數組是否為索引數組。 function is_assoc($arr){ return array_keys($arr) !== range(0, count($arr) - 1); // array_values($arr) !== $arr } function is_assoc2($array) { return (bool)count(array_filter(array_keys($array), 'is_string')); }
Time of Update: 2016-07-25
php如何轉換html標籤,使其能在瀏覽器中正常顯示?在編程中需要把提交的內容轉化成html標籤,這樣才能在瀏覽器中正常顯示。比如要把'其實php已有這樣的函數html_entity_decode。例子: $new = htmlspecialchars("Test"); echo $new; //out <a href='test'>Test</a> echo html_entity_decode($new); //out Test ?>複製代碼
Time of Update: 2016-07-25
1、this是指向當前對象的指標 例如:同class裡面的其他函數可以用 this->函數名 調用。 2、self是指向當前類的指標 一般self使用來指向類中的靜態變數,還要注意使用self來調用靜態變數必須使用:: (域運算子號) 例如:self::$firstCount; //使用self來調用靜態變數複製代碼3、parent是指向父類的指標 一般使用parent來調用父類的建構函式 例如:parent::__construct( "PBPHome");
Time of Update: 2016-07-25
擷取頁面內容的一個函數 function getwebdate($url){ $tmp = str_replace('http://', '', $url); $domain = substr($tmp, 0, strpos($tmp, '/')); $path = strstr($tmp, '/'); $fp =
Time of Update: 2016-07-25
為大家介紹apache和php的工作原理。假設有1000個人同一時刻請求php網站,這些請求傳給apache伺服器,這個時候apache伺服器是怎麼來工作的?1.建立1000個進程來處理1000個請求?2.建立很多個進程,這些進程又包含很多線程來處理1000個請求?3.其他?還有fast-cgi,和cgi及php-fpm區別。用上述例子來闡述。延伸閱讀: Nginx中的FastCGI模組(FastCGI)詳解 Nginx學習筆記之有關FastCGI的知識
Time of Update: 2016-07-25
//執行個體化檔案上專類$fName=$this->_request->getPost('fName');$adapter = new Zend_File_Transfer_Adapter_Http();//存放上傳檔案的檔案夾$adapter->setDestination('/opt/lampp/htdocs/blog/upload');//上傳配置$adapter->addValidator ( 'Extension', false,
Time of Update: 2016-07-25
例子,中文字串截取函數代碼。 //樣本/*echo csubstr(“123中國人jbxue.com”,0,4);echo csubstr(“123中jbxue國人”,2,6);*///---中文字串截取--- function csubstr($str,$start,$len) { $strlen=strlen($str); if ($start>=$strlen) return $str; $clen=0; for($i=0;$i {
Time of Update: 2016-07-25
例子,php讀取mysql資料。 $hostname = "localhost:3306"; $username = "root"; $password = "root"; $dbname = "test"; $conn = mysqli_connect($hostname, $username, $password, $dbname); $conn->query("SET NAMES 'gbk'"); // Check connection if
Time of Update: 2016-07-25
function dump_urls(tidy_node $node, &$urls = NULL) { $urls = (is_array($urls)) ? $urls : array(); if(isset($node->id)) { if($node->id == TIDY_TAG_A) { $urls[] = $node->attribute['href'];
Time of Update: 2016-07-25
IP 地理位置查詢類 /** 檔案名稱:IpLocation.class.php* IP 地理位置查詢類 (主檔案我上傳上來了 還有一個測試檔案我上傳上來,同時還有一個QQWry.Dat這個大家可以在純真IP庫下載到 因為有6M多 所以這裡不上傳上來了)* * @author 馬秉堯 * @version 1.5 * @copyright 2005
Time of Update: 2016-07-25
看到總有人問curl的問題,這兩天沒事寫了個採集論壇的小程式。裡麵包括了類比登陸,擷取頁面原始碼,正則匹配結果等部分,希望對大家有用。 set_time_limit(0);//cookie儲存目錄$cookie_jar = '/tmp/cookie.tmp';/*函數-----------------------------------------------------