One, in a function, it is more efficient to pass an array using return than to use global, such as:
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
Second, (this code 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 piece of code is more
$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 to determine the ratio is equal to efficient
$a =2; $b = 2;
Like what
if ($a = = $b) $c = $a;
Than
if ($a = = = $b) $c = $a;
Efficient
When MySQL queries, try to use where in less limit
Limit check many records of the first few, fast, but the query the most face will be slow
With in. On query continuity records, very fast, non-continuity records run slightly slower for the first time, but then faster!
V, NT Server data operation stability is less than unix/linux
Vi. use Ob_start () as far as possible before output;
Can speed up output, applicable NT or Nuli/linux, if use Ob_start (' Ob_gzhandler ') for Unlix Class Server, output efficiency will be higher
When judging, try to use if ($a = = his value)
Try to use if (empty ($a)) when negative, because it runs faster
Viii. the use of unequal! = is equivalent to <> efficiency
Ix. the use of personal experience $a = "11111111111111"; The efficiency and $a = ' 11111111111111 '; Not quite as much as the book says.
Ten, the use of standard SQL statements, will facilitate the analysis of MySQL
Xi. Use of
if ($online) {
$
Setcookie (' Online1 ', $online, $cookietime, $ckpath, $ckdomain, $secure);
}
The cookie will take effect immediately.
Use
if ($online)
Setcookie (' Online1 ', $online, $cookietime, $ckpath, $ckdomain, $secure);
The cookie needs to be refreshed again to take effect
12. Use
$handle =fopen ($filename, WB);
Flock ($handle, lock_sh);
$filedata =fread ($handle, FileSize ($filename));
Fclose ($handle);
Than
File ($filename);
Be good at speed or stability
Current 1/2 Page 12 next page
The above describes the improvement of the speed of the mobile phone PHP optimization and efficient implementation of the problem 1th/2, including the speed of the mobile phone to improve the content, I hope that the PHP tutorial interested in a friend helpful.