1, If A can be static, declare it static. Speed improvement is by a factor of 4.
1, if a function can be declared static, then use static, speed is an improvement of a factor of 4.
2, # Avoid magic like __get, __set, __autoload
2, avoid using __get, __set, __autoload and other magic functions
3. require_once () is expensive
3, require_once () is quite expensive.
4. Use full paths in includes and requires, less time spent on resolving the OS paths.
4, with include and require, as far as possible with the full path, you can reduce the time spent on the solution of the OS path
5, If You need the scrīpt started executing, $_server[' request_time ' are preferred to time ()
5, if you need to know a script to start running time, with $_server[' request_time '] better than Time ()
6. If can use STRNCASECMP, strpbrk and stripos instead of regex
6, if you can use STRNCASECMP, strpbrk and Stripos do not use regular
7, Preg_replace is faster than Str_replace, but strtr are faster than preg_replace by a factor of 4
7, Preg_replace faster than Str_replace, but strtr faster than preg_replace
8, if the function, such as String replacement function, accepts both arrays and single characters as arguments, and if R argument list is not too long, consider writing a few redundant replacement statements, passing one character in a time, Instead of one line of code that accepts arrays as search and replace arguments.
Some functions, such as string substitution functions, accept arrays and single characters as arguments, and if your argument list is not very long, consider writing redundant statements, sending one character at a time, instead of a line of code to accept the array as an argument for finding and replacing.
9, the Error suppression with the @ is very slow.
9, prohibit the wrong output symbol @ is very slow.
10, $row [' ID '] is 7 times faster than $row [ID]
10,, $row [' ID '] is 7 times times faster than $row [ID]
11, Error messages are expensive
11, the error message is very expensive
12. Do not use functions inside of a for loop, such as for ($x =0; $x < count ($array); $x) the count () function gets called Each time.
12, do not use functions within the loop, such as: for ($x =0; $x < count ($array); $x). The count () function is invoked in each loop.
Are you using Smarty for templates? This is probably the quickest way to ensure that the most frequently accessed pages are cached.
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.