Ten Principles of PHP development

Source: Internet
Author: User
Tags php and

1. Use PHP at the right time

No one is more reasonable than PHP's creator Rasmus Lerdorf understand where PHP is used, he released the language of PHP in 1995, and since then PHP has been like a prairie fire, burning the entire development camp and changing the world of the Internet. However, Rasmus does not create PHP for this reason. PHP was created to solve the real problem of web developers.

Like many open source projects, PHP became popular, and the motivation of popular motives was not explained by normal philosophy, or even a bit narcissistic. It can be a case in point, a case of a tool that solves a variety of web problems, so when PHP first appears, the tool needs all focus on PHP. But you can't expect PHP to solve all the problems. Lerdorf is the first person to admit that PHP is just a tool, and PHP has a lot of power to do. As a web developer, trying to solve all the problems with PHP is unscientific and wastes your time. When PHP is not playing, do not hesitate to try other languages.

2. Improve scale scalability with multiple table storage

If you want to extend its scalability, the price is too high. If you use a whole data structure, in front of large traffic, you will face the problem of server hardware. In Mu. Users are distributed to separate tables and can be easily organized. For example, WordPress.com stores the user's data in 4,096 databases, which can disperse large-scale data access to achieve flow and pressure streaming. The mobility of datasheets allows code (blogs) to run faster and make the system more scalable. Relying on a powerful caching strategy and a flexible database strategy, Matt showed people that the most popular Facebook and wordpress.com can run stably under PHP and handle amazing traffic.

3. Don't trust users

There is a basic principle of web development, I repeat how many times that is not enough, that is: do not trust your users, but also assume that every data unit in your site is the malicious code collected from the user. Most of the time, you have to use JavaScript in the client to check the form submitted over the content, if you are accustomed to this, then, this is a good habit. If security is important to you, this is the most important principle you need to learn most.

4. Multi-use PHP cache

Ben Balbo has developed site Point, a website that provides guidance for developers and designers. He is a member of the Melbourne PHP development and Open Source Club, so he has a certain understanding of PHP, and has some ideas and experience for PHP caching. If you have a site with a lot of traffic, but not very frequent updates (such as blogs, based on some kind of CMS), perhaps it needs some transformation, which will not take much time, but can make a significant contribution to performance. The process can be tortuous, but the benefits are obvious if you want to create a caching mechanism for a complex/frequently updated site.

5. Use IDE, templates and snippets to accelerate PHP development

Because of the all-round development of Chad, he can often find problems that other programmers can't find and develop relevant experience, especially the way he develops the website. He is involved in all aspects of the site development, so his advice is useful for improving the development of the site. Chad that using the IDE such as Eclipse PDT, while using some template technology and open source projects, can effectively improve PHP's development speed. The compact plan, the long to do lists, and the deadlines make the developers very depressed. However, some features, such as Eclipse Templates, can effectively reduce coding time and error probability. In general, any project can be automated, and the higher the level of automation, the less time you will have to complete the project. Taking the time to develop frameworks and templates that use a high frequency will save you more time. At the same time, using an IDE like Eclipse and the PDT package, you will see a significant improvement in efficiency, the IDE can automatically close, complete the semicolon, and can debug locally.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.