Code-How to Improve PHP code Stability

Source: Internet
Author: User
How can we improve the stability of PHP code? What is the stability of PHP code? How can we improve the stability of PHP code? What is the stability of PHP code?

Reply content:

How can we improve the stability of PHP code? What is the stability of PHP code?

Improving error handling and exception handling should improve code stability.

In combination with the projects I have participated in, I think that the outstanding php code is just like a horse.

  1. The most basic solution is to solve all the notice, warning, and error errors in the php code. I have seen some code that cannot solve these basic problems.
  2. Properly plan the directory structure of the Code. It is best to reflect the MVC idea.
  3. Uniform encoding style, fig-standards is recommended
  4. Annotations are clear and easy to understand. English is good. If English is not good, do not be reluctant. It is good to describe Chinese clearly.
  5. For scalability and portability, you can consider the idea of adding design patterns to the Code. For portability, pay attention to whether the agent is using APIs specific to the current environment. If so, use function_exists to judge, the current api method does not exist.
  6. Code security: Basic SQL injection or xss attacks must be prevented.
  7. Exception formulation and handling

Basically do the above several items well. At least in team development, your code will not become a burden on others.

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.