[Size=5] [Color=red] 40 Suggestions for optimizing PHP code [/color][/size]Tips for optimizing your PHP CodeOriginal address: Http://reinholdweber.com/?p=3The English copyright belongs to Reinhold Weber, the author of Yangyang (aka Davidkoree). The bilingual version may be used for non-commercial communication, provided that the English version of the author, copyright information, and the author of the Chi
replaces a function that accepts an array or character as an argument, and the parameter length is not too long, consider writing an additional replacement code so that each pass argument is a character instead of just one line of code that accepts the array as a parameter for querying and replacing. 13. Use the Select Branch statement (that is, switch case) better than using multiple if,else if statemen
40 tips to optimize your PHP code
The English copyright belongs to Reinhold Weber, the author of Yangyang (aka Davidkoree). The bilingual version may be used for non-commercial communication, provided that the English version of the author, copyright information, and the author of the Chinese translation.
1. If a method can be static, declare it static. Speed improvement are by a factor of if a method is
n) { vectorCombination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations in C Where the candidate numbers sums to T.The same repeated number is chosen from C unlimited number of times.Note:
All numbers (including target) would be positive integers.
elements in a combination (a 1 , a 2 , ..., a k ) must is in non-descending order. (Ie,a 1 ≤a 2 ≤ ... ≤a k ).
The solution set must not contain duplicate combinations.
For exampl
receives the client request), use $_server[' request_time '] better than time ().10. function instead of regular expression to complete the same function.The 11.str_replace function is faster than the Preg_replace function, but the efficiency of the STRTR function is four times times that of the Str_replace function.12. If a string replaces a function that accepts an array or character as an argument, and the parameter length is not too long, consider writing an additional replacement
the parent class's Flushbuffer method, copies the data that might not have been copied to the Dfsoutputstream, and then calls Flushinternal, waiting for all the data to be written. Then call Namenode.fsync to persist the data on the namespace.Closeinternal is a bit more complicated, it first calls the parent class's Flushbuffer method, copies the data that might not have been copied to Dfsoutputstream, and then calls Flushinternal, waiting for all the data to be finished. Then end the two worke
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.