1,在函数中,传递数组时
使用 return 比使用 global 要高效比如
function userloginfo($usertemp){
$detail=explode("|",$usertemp);
return $detail;
}
$login=userloginfo($userdb);
比
function userloginfo($usertemp){
global $detail;
$detail=explode("|",$usertemp);
}
userloginfo($userdb);
要高效
2,(这个代码用于得到程序目录对应的网址,推荐使用)
$urlarray=explode('/',$HTTP_SERVER_VARS['REQUEST_URI']);
$urlcount=count($urlarray);unset($urlarray[$urlcount-1]);
$ofstarurl='http://'.$HTTP_SERVER_VARS['HTTP_HOST'].implode('/',$urlarray);
这段代码比
$pre_urlarray=explode('/',$HTTP_SERVER_VARS['HTTP_REFERER']);
$pre_url=array_pop($pre_urlarray);
要高效
3,在循环中判断时,数值判断使用恒等要比等于高效
伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-02/1170384311.html
$a=2;$b=2;
PHP代码优化及PHP相关问题总结
'http://www.etoow.com/html/2007-02/1170384311.html