你的團隊成員提出,這些年php引擎已經有不少象徵性的性能提高。若是你的web server仍然運行着比較老的版本,如php3或者php4。那麼在你嘗試着優化你代碼以前,應該先深刻調查一下版本之間的升級狀況。php
點擊如下連接,能夠了解具體細節: html
class dog { public $name = ''; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } }
注意:setName()和getName()除了存儲和返回name屬性外,沒作任何工做。mysql
$rover = new dog(); $rover->setName('rover'); echo $rover->getName();
直接設置和訪問name屬性,性能能提高100%,並且也能縮減開發時間!web
$rover = new dog(); $rover->name = 'rover'; echo $rover->name;
$description = strip_tags($_POST['description']); echo $description;
echo strip_tags($_POST['description']);
foreach ($userList as $user) { $query = 'INSERT INTO users (first_name,last_name) VALUES("' . $user['first_name'] . '", "' . $user['last_name'] . '")'; mysql_query($query); }
過程:sql
INSERT INTO users (first_name,last_name) VALUES("John", "Doe")
替換這種循環方案,你可以拼接數據成爲一個單一的數據庫操做。數據庫
$userData = array(); foreach ($userList as $user) { $userData[] = '("' . $user['first_name'] . '", "' . $user['last_name'] . '")'; } $query = 'INSERT INTO users (first_name,last_name) VALUES' . implode(',', $userData); mysql_query($query);
過程:緩存
INSERT INTO users (first_name,last_name) VALUES("John", "Doe"),("Jane", "Doe")...