Php code optimization and php related title Summary
Source: Internet
Author: User
1. when passing an array in a function, application return is more efficient than application global, for example, functionuserloginfo ($ usertemp) {$ detail = explode ("|", $ usertemp ); return $ detail;} $ login = userloginfo ($ userdb); compared with func 1, when passing an array in a function
Application return is more efficient than application global
For example
3. in the cycle, it is more efficient to use constant for numerical determination.
$ A = 2; $ B = 2;
For example
If ($ a ==$ B) $ c = $;
Ratio
If ($ a ===$ B) $ c = $;
Efficient
4. try to use where in for mysql Query with less limit
Limit queries the first few records of multiple records, which is fast, but the query speed is slow
Application in. the query of persistent records is very fast. the first running of non-persistent records will be a little slower, but it will be faster later!
5. NT Server data control is less stable than unix/linux
6. try to apply ob_start () to the application before output. it can speed up the output speed and be used in NT or nuli/linux. for unlix servers, if ob_start ('OB _ gzhandler') is used '); higher output efficiency
7. try to apply if ($ a = his value) when determining whether to apply if (empty ($ a) whenever possible, because the program runs faster.
8. application time is not equal! = Equivalent to <> efficiency
9. the efficiency of applying $ a = '000000' in personal experience is quite different from that in $ a = '000000 '.
10. the application of standardized SQL statements will facilitate MySQL parsing.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service