This post was last edited by wheat at on May 11 ,.
1407901013l587645792.jpg (20.17 KB, Downloads: 5) Download attachment Php Development habits-wheat Institute Upload As the saying goes, details determine success or failure. developing good habits will be of great benefit to your success. The following small series summarizes the excellent habits of the top ten PHP gods, learning and transforming them into their own habits, so that you can change your mind in minutes.
1, Read more manuals and source code There is nothing to emphasize more than reading the PHP Development Manual. you can learn a lot through reading the manual, especially many functions related to strings and arrays. Many useful functions are included in these functions. if you carefully read the manual, you will often find that in the previous project development process, you often "reinvent the wheel ", in fact, you only need a core function to complete the corresponding functions. In addition, there are many open-source programs developed using PHP. why don't you learn from them? Download the source code of an open-source PHP application. read it carefully. Maybe the larger the project, the more worth reading. although they may have more complex structures and systems, there are more detailed explanations.
2, Write modular code Good PHP code should be modular code. PHP's object-oriented programming functions are powerful tools that can break down your applications into functions or methods. You should split the front-end HTML/CSS/JavaScript code from the server of your application as much as possible. you can also follow MVC (Model-View-Controller) on any PHP framework) mode.
3Code writing specifications Good PHP code should have a complete set of coding specifications. By naming variables and functions, you can use uniform methods to access the database, handle errors, and indent the same code to achieve programming specifications. This makes your code more readable.
4, Write portable code Good PHP code should be portable. You can use existing php functions, such as magic quotes and short labels. Try to understand your needs, and then write code to make the code INDEPENDENT and portable by adapting to PHP features.
5, Write security code Good PHP code should be safe. PHP5 provides excellent performance and flexibility, but the security problem lies completely with developers. For a professional PHP developer, it is critical to have a deep understanding of major security vulnerabilities, such as cross-site scripting (XSS) and cross-site request forgery (CSRF), code injection, and character encoding vulnerabilities. You can write secure code by using special PHP functions, such as mysql_real_escape_string.
6, Code comment Code annotation is an important part of code. Through code annotation, you can know what the variable or function is, which will be very useful in later code maintenance.
7Use single quotes instead of double quotes The string always uses single quotes instead of double quotation marks to avoid performance degradation caused by PHP search for variables in the string. Use single quotes instead of double quotes to include strings, which is faster. Because PHP searches for variables in strings enclosed by double quotation marks, but not in single quotes.
8Escape string output It is a good habit to pass ENT_QUOTES as a parameter to the htmlspecialchars function to ensure that single quotes (') are also converted to HTML entities.
9, Use commas to separate string output Using echo statements to output strings separated by commas (,) is better than using the string concatenation operator.
10Check the sent values before output. Check the passed value $ _ GET ['query'] before output. The isset or empty function can be used to check whether the variable is null.
Php Development programmers, do you know? If you understand it, hurry up and add it to your favorites ~~
PHP Tutorial (http://www.maiziedu.com/course/14) Source: web developers
|