Home > Backend Development > PHP Tutorial > PHP master's advice: How to come up with excellent PHP code?_PHP Tutorial

PHP master's advice: How to come up with excellent PHP code?_PHP Tutorial

WBOY
Release: 2016-07-21 14:57:25
Original
970 people have browsed it

Original text: http://nettuts.com/articles/10-principles-of-the-php-masters/

With the popularity of PHP, you can just find a paragraph Code to achieve the desired function, but what kind of code is considered excellent code? At this time, we need the guidance of masters

1. Use PHP only when needed——Rasmus Lerdorf (Founder of PHP)


Don’t let PHP do everything, PHP is just a tool, and every language has its own limitations
When PHP can’t solve the problem, don’t be afraid to use other languages

2. Use as many tables as possible in MySQL——Matt Mullenweg (Founder of wordpress)



3. Never trust your users - Dave Child

Dave Child is the creator of Added Bytes (formerly: www.ilovejackdaniels.com). Created cheat sheet (getting started notes) for several languages ​​

Dave wrote several articles about PHP, and his final advice was this:

Be absolutely paranoid. If you don’t want your website to be attacked all the time or have various problems, then assume that every user is malicious and you will be on alert for a long time, which will make your website more secure

4. Pay attention to cache——Ben Balbo

Ben Balbo writes articles for sitepoint. He is the leader of the PHP discussion group and open source group. He recommends spending more time on PHP caching.

For websites that change little, such as blogs, you can achieve obvious results by setting up cache. If it is a slightly more complex website, such as shopping, there are higher requirements for cache settings, but the results are usually very good. In fact, in essence, caching is to store content that is frequently used but does not change much

5. Speed ​​up development through IDE, templates or code snippets - Chad Kieffer



6. Use PHP’s filter function - Joey Sochacki

You need to install the filter plug-in, which is not universal, so ignore

7. Use PHP framework - Josh Sharp

Using a framework can save time and eliminate errors because PHP itself is so easy to learn. Precisely because PHP does not have too strict restrictions, it is easy to write non-standard code. The solution is to use a framework. You can take a look at his article "Benefits of Using Frameworks"

8. Don’t use PHP framework——Rasmus Lerdorf

Keeping up with the opposing views, the biggest reason lies in execution efficiency.

At the Drupalcon 2008 conference, Rasmus compared the execution efficiency of pure PHP and several frameworks through several "hello world". The results proved that the execution efficiency of the PHP framework is much lower than that of pure PHP Code

[If you want to use a php framework, Rasmus recommends CodeIgniter (I recommend Kohana, haha), because it is "least like a framework"]

9. Use multi-threading - Jack D. Herrington


10. Open a bug report immediately - David Cummings

What I most want to say to PHP developers is: adjust the error reporting level to the highest level. See "2 quick php tips" for details, this will save a lot of time in the long run.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364052.htmlTechArticleOriginal text: http://nettuts.com/articles/10-principles-of-the-php-masters/ With the popularity of PHP, you can just find a piece of code to achieve the desired function, but what kind of code is...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template