Time of Update: 2016-07-13
複製代碼 代碼如下:function isMobile(){ $useragent=isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $useragent_commentsblock=preg_match('|\(.*?\)|',$useragent,$matches)>0?$matches[0]:''; function CheckSubstrs($substrs,$text){
Time of Update: 2016-07-13
有時候我們為了隱藏真實的下載地址,我們通過採用header定義為檔案然後readfile下載,但這樣會加大伺服器的負擔,一般不建議下載量比較大的檔案代碼如下:= $lastModified) { header("HTTP/1.1 304 Not Modified"); return true; } if (isset($_SERVER['HTTP_IF_UNMODIFIED_SINCE']) &&
Time of Update: 2016-07-13
這篇文章主要介紹了使用openssl實現rsa非對稱式加密演算法的樣本,大家參考使用吧 代碼如下:_keyPath = $path; } /** * create the key pair,save the key to $this->_keyPath */ public function createKey() { $r = openssl_pkey_new();
Time of Update: 2016-07-13
php 提供的字串壓縮方法有 1.gzcompress — Compress a string This function compress the given string using the ZLIB data format. 2.gzencode — Create a gzip compressed string This function returns a compressed version of the input data compatible with the output
Time of Update: 2016-07-13
php-screw版本問題,報錯 make /bin/sh /root/php_screw-1.5/libtool --mode=compile cc -I. -I/root/php_screw-1.5 -DPHP_ATOM_INC -I/root/php_screw-1.5/include -I/root/php_screw-1.5/main -I/root/php_screw-1.5 -I/usr/include/php -I/usr/include/php/main
Time of Update: 2016-07-13
今晚在寫架構的表單驗證類時,需要判斷某個字串長度是否在指定區間內,很自然地,想到了PHP中的strlen函數。 代碼如下 $str = 'Hello world!中'; echo strlen($str); // 輸出12 測試一下中文
Time of Update: 2016-07-13
一、程式碼片段開發人員很多時候是在做一些重複的工作。針對不同資料表的增刪改查都差不多,重複來重去的。很久不寫程式了,利用十一假期在家看看書,寫寫程式。最近一直很喜歡使用Sublime Text,發現它的代碼片斷管理功能不錯,只要輸入事先定義好的短語,大段的程式碼片段就可以自動填滿進來。還可以定義變數。如PHP代碼。可以使用 ${0}的方式定義每一個參數,其它依次類推。如果想在程式碼片段中保留$符,只要在$前面加上\就可以了。如: \$data設定步驟如下:1,選擇Tools -》 New
Time of Update: 2016-07-13
php抓取網頁圖片PHP是一門很容易上手的Web程式設計語言。PHP學習成本很低,能夠迅速開發各種Web應用,是一個很優秀的工具。儘管很多人覺得PHP缺點很多,quick and dirty 之類的,但是“這個世界上只有兩種程式設計語言,一種是飽受爭議的,一種是沒人用的”,不是嗎?只要能夠把事情做好的工具,就是好工具。PHP就是這麼一個優秀的語言工具。'; get_name1($arr_src1); get_name1($arr_src2); get_name1($arr_src3);
Time of Update: 2016-07-13
不多說,代碼送上: function Pinyin($_String, $_Code='gb2312'){$_DataKey =
Time of Update: 2016-07-13
複製代碼 代碼如下:session_start();if($_SESSION['Company']==''){ //exit();}?>$uptypes=array('image/jpg','image/jpeg','image/png','image/pjpeg','image/gif','image/bmp','application/x-shockwave-flash','image/x-png'); $max_file_size=5000000; //上傳檔案大小限制,
Time of Update: 2016-07-13
導讀:PHP在產生靜態檔案的時候,有時候會因為一些混編問題讓HTML標籤不完整或混亂而導致頁面混亂。作者分享下面這段小代碼可以非常方便解決問題。 如果你的網頁內容的html標籤顯示不全,有些表格標籤不完整而導致頁面混亂,或者把你的內容之外的局部html頁面給包含進去了,我們可以寫個函數方法來補全html標籤以及過濾掉無用的html標籤. php使HTML標籤自動補全閉合函數方法如下: function closetags($html) { preg_match_all('
Time of Update: 2016-07-13
php 啟動報錯 複製代碼 代碼如下: [root@abc lnmp]# service php-fpm start Starting php-fpm eAccelerator: Could not allocate 67108864 bytes, the maximum size the kernel allows is 33554432 bytes. Lower the amount of memory request or increase the limit in
Time of Update: 2016-07-13
demon認為一個優秀的架構並不是完成僅有的幾個業務流,它應該是可擴充的,是富有的,是集合,是離散。簡單說它是萬物的矛盾體,既游離又彙總。體積切入: 架構體積cake_1
Time of Update: 2016-07-13
之前也有一些介紹大型網站架構演變的文章,例如LiveJournal的、ebay的,都是非常值得參考的,不過感覺他們講的更多的是每次演變的結果,而沒有很詳細的講為什麼需要做這樣的演變,再加上近來感覺有不少同學都很難明白為什麼一個網站需要那麼複雜的技術,於是有了寫這篇文章的想法,在這篇文章中
Time of Update: 2016-07-13
下面總結了18條php代碼書寫中可以做的最佳化習慣,以最大限度的保證php代碼執行的快速性!(1)使用 static 靜態方法比普通方法快4倍(2)echo輸出快於print(3)串連字元使用 , 代替 .(4)迴圈之前先取出最大值,而不是在迴圈裡面取值 正確的方法 $max = count($array); for ($i=0;$i echo $i; } 錯誤的方法 for ($i=0;$i echo $i; }
Time of Update: 2016-07-13
複製代碼 代碼如下:$json='{ "rec_items": [ { "classes": "玄幻", "gid": 6326585, "author": "我吃西紅柿", "nid": 10079306, "last_sort": 841, "last_chapter_name": "第二十五卷 第六章 一掃而空", "
Time of Update: 2016-07-13
basename — 返迴路徑中的檔案名稱部分dirname — 返迴路徑中的目錄部分複製代碼 代碼如下:string basename ( string $path [, string $suffix ] )string dirname ( string $path )樣本:複製代碼 代碼如下:$path = "/home/httpd/phpha.com/index.php";echo basename($path);echo basename($path, '.php');echo
Time of Update: 2016-07-13
電腦環境 win7 64位 搭建 apache-httpd-2.2-win64 + php-5.3.6-Win32-VC9-x64 +MySQL_5.5.13_winx64開發環境 安裝過程遇到的問題: 1.PHP版本問題,必須下載對應apache的版本才會有php5apache2.dll庫,(apache去調用php組件需要載入該庫); 2.注意設定檔案存取權限; 3.httpd.conf修改後,需要重啟apache
Time of Update: 2016-07-13
英文: 代碼如下 function tourl($str) { $str = preg_replace('/[^a-zA-Z0-9]+/', '-', $str); $str = trim($str, '-'); return strtolower($str)
Time of Update: 2016-07-13
$logo = 'logo.png'; if(is_file($logo)) { $QR = imagecreatefromstring(file_get_contents($filename)); $logo = imagecreatefromstring(file_get_contents($logo)); $QR_width = imagesx($QR); $QR_height = imagesy($QR); $logo_width = imagesx($logo);