in a function, it is more efficient to use return than to use global when passing an array, for example:
function Userloginfo ($usertemp) {
$detail =explode ("|", $usertemp);
return $detail;
}
$login =userloginfo ($USERDB);
than
function Userloginfo ($usertemp) {
Global $detail;
$detail =explode ("|", $usertemp);
}
Userloginfo ($USERDB);
to be efficient
II, (this code is used to get the program directory corresponding URL, recommended)
$urlarray =explode ('/', $HTTP _server_vars[' Request_uri ');
$urlcount =count ($urlarray); unset ($urlarray [$urlcount-1]);
$ofstarurl = ' http://'. $HTTP _server_vars[' http_host '].implode ('/', $urlarray);
This code is more than
$pre _urlarray=explode ('/', $HTTP _server_vars[' http_referer ');
$pre _url=array_pop ($pre _urlarray);
to be efficient
third, in the cycle of judgment, the value of the use of identity is equal to the efficient
$a =2; $b = 2;
like
.
if ($a = = $b) $c = $a;
than
if ($a = = = $b) $c = $a;
Efficient
Four, MySQL query when possible to use where in less limit
limit check many records of the first few, fast, but the most of the query will be slow
use in. On query continuity records, very fast, discontinuous records first run will be slightly slower, but later will be faster!
Five, NT Server data operation stability is less than unix/linux
Six, use the Ob_start () as far as possible before the output;
can speed up output, apply NT or Nuli/linux, use Ob_start (' Ob_gzhandler ') for Unlix class servers, and output efficiency will be higher
Seven, try to use if ($a = = his value) when judging
Use if (empty ($a)) as much as possible, because the program runs faster
viii.!= and <> efficiency are quite
when use is unequal
Nine, personal experience to use $a = "11111111111111"; The efficiency and $a = ' 11111111111111 '; Quite. Not as much as the book says.
10, the use of standardized SQL statements, will be conducive to the analysis of MySQL
11, using
if ($online) {
$online 1= $online;
Setcookie (' Online1 ', $online, $cookietime, $ckpath, $ckdomain, $secure);
}
cookies will take effect immediately
Use
if ($online)
Setcookie (' online1 ', $online, $cookietime, $ckpath, $ckdomain, $secure);
cookies need to be refreshed again to take effect
12, using
$handle =fopen ($filename, WB);
Flock ($handle, lock_sh);
$filedata =fread ($handle, FileSize ($filename));
fclose ($handle);
than
file ($filename);
must be excellent in speed and stability
Current 1/2 page
12 Next read the full text