日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

PHP技巧:優(yōu)化動態(tài)網(wǎng)頁技術PHP程序的12條技巧_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:PHP技巧:通過實例深入剖析require和include的用法
在php中,include和require的作用比較容易混淆。下面我以一個經(jīng)典例子來深刻說明它們的區(qū)別。 當我們經(jīng)常訪問一個數(shù)據(jù)庫時,可以把連庫語句寫成一個文件

1、If a method can be static, declare it static. Speed improvement is by a factor of 4。

1、如果一個函數(shù)可以聲明為靜態(tài)的,那么就用靜態(tài)的,速度是改進的一個因素4。


2、# Avoid magic like __get, __set, __autoload

2、避免使用__get, __set, __autoload等魔術函數(shù)


3、require_once() is expensive

3、require_once()是相當昂貴的。


4、Use full paths in includes and requires, less time spent on resolving the OS paths.

4、用include和require時,盡量用全路徑,可以減少花在解決OS路徑的時間


5、If you need to find out the time when the scrīpt started executing, $_SERVER[’REQUEST_TIME’] is preferred to time()

5、如果你需要知道一個腳本的開始運行時間,用 $_SERVER[’REQUEST_TIME’]比用time()要好


6、See if you can use strncasecmp, strpbrk and stripos instead of regex

6、如果可以用strncasecmp, strpbrk and stripos就別用正則


7、preg_replace is faster than str_replace, but strtr is faster than preg_replace by a factor of 4

7、preg_replace比str_replace要快,但是strtr比preg_replace更快


8、If the function, such as string replacement function, accepts both arrays and single characters as arguments, and if your argument list is not too long, consider writing a few redundant replacement statements, passing one character at a time, instead of one line of code that accepts arrays as search and replace arguments.

一些函數(shù),比如字符串替換函數(shù),接受數(shù)組和單個字符做為參數(shù),并且如果你的參數(shù)列表不是很長,考慮寫一些冗余替換語句,每次傳送一個字符,代替一行代碼接受數(shù)組做為查找和替換的參數(shù)。


9、Error suppression with @ is very slow.

9、禁止錯誤輸出符號@是非常慢的。


10、$row[’id’] is 7 times faster than $row[id]

10、、$row[’id’]比 $row[id]快7倍


11、Error messages are expensive

11、錯誤信息是非常昂貴的


12、Do not use functions inside of for loop, such as for ($x=0; $x < count($array); $x) The count() function gets called each time.

12、不要在循環(huán)內(nèi)部使用函數(shù),比如: for ($x=0; $x < count($array); $x)。count()函數(shù)在每次循環(huán)中都會被調(diào)用。


對于模板,你是否在用smarty?這可能是保證把最經(jīng)常訪問的頁面緩存起來的最快的方法了。

分享:PHP技巧:分析利用PHP制作新聞系統(tǒng)的步驟
我們可以用新聞系統(tǒng)來存儲新聞,我們可以對新聞進行添加、刪除等操作,這樣減少了大家的工作量,為什么不實驗一下。 首先,建立一個表。 以下為引用的

來源:模板無憂//所屬分類:PHP教程/更新時間:2008-08-22
相關PHP教程