In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to improve the performance of PHP code, the article is very detailed, has a certain reference value, interested friends must read it!
1.echo is much faster than print. Both methods print something on the page, but echo does not return any value, and print returns 0 or 1 on success or failure.
2.include_once is more time consuming than include. Because it needs to check whether the class you want to include has already been included.
3. Be sure to use single quotation marks instead of double quotation marks for long paragraph strings. Because double quotation marks search for variables in the string. For example, echo 'This is long string'.$name is much faster than echo "This is long string $name".
4. Do not use for in the loop ($item0
5. If you can define a function as static, then don't define it as a member function. Static functions are 33% faster than member functions.
6. If you can solve the problem without using regular expressions, don't use regular expressions. Regular expressions are slower than PHP native functions. For example, use str_replace instead of preg_replae.
7. Try not to use relative paths to include files. If you look for a file in the relative path, it will look in the current directory now, and then look for it again. This makes it very slow to find files. * defines a constant such as WEB_ROOT, and then uses this constant to include files.
8. The congruent sign = is faster than the equal sign. And if (1 = ='1') returns true,if (zero = ") and true, while if (1 ='1') and if (zero equal =") both return false when you use congruent symbols. So use congruent symbols when you need to detect some Boolean variables in the program.
9. Don't use abbreviations
Don't use and rely on register_global or magic_quote, and be careful when reading and setting up your php.ini.
These are all the contents of the article "how to improve the performance of PHP Code". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.