Php experts gave us 13 good habits and guidance

Source: Internet
Author: User
As a half-bottle phper, source code enthusiasts have encountered many problems during the development process, and do not pay attention to code specifications during the development process, if you have encountered many difficulties, search for the suggestions provided by php experts here.

As a half-bottle phper, source code enthusiasts have encountered many problems during the development process, and do not pay attention to code specifications during the development process, if you have encountered many difficulties, search for the suggestions provided by php experts here. suggestions provided by php experts:

1. when using select to query information from the same database, use a join statement to get all the information you need in a neat manner at a time, instead of writing multiple mysql_query/while/mysql_fetch_array statements.

2. if you call a database connection in multiple files, create a connection. php file to save your connection variables and include the file as needed.

3. for small projects, write all your functions in a file. for large projects, write them in an object and include the file where necessary.

4. if your included files are out of control, you can create an include file that contains all. inc files and include this include file as needed.

5. compile a document for your code. you will need it when you read the code three months later.

6. code formatting is nothing more important than readability.

7. separate the logic and presentation layers.

8. when writing a class, make sure you know when is the best time for coupling and when is the best time for expansion.

9. the interface is your friend.

10. as projects become larger and larger, splitting your code into models, views, and controllers is a super scam.

11. never output POST and GET data before the HTML tag is removed,

12. never trust user input, even if she is your mother.

13. never repeat the class name. Remember, always!

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.