That is, the 13 PHP coding habits listed in this article. If you have better suggestions, you are welcome to post them in the comments below this article. I like to learn.
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!