English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP master cultivation record, the specific content is as follows
1Read the manual and source code more often
There is nothing more important to emphasize than reading the manual – just by reading the manual, you can learn a lot, especially many functions related to strings and arrays. Many useful features are included in these functions. If you read the manual carefully, you will often find that in many previous project development processes, you are often 'reinventing the wheel', and in fact, you only need a core function to complete the corresponding function. The manual is your friend. In addition, there are many open-source programs developed using PHP. Why not learn and refer to them? Download the source code of an open-source PHP application and read it carefully. Perhaps larger projects are worth reading, although they may have more complex structures and systems, they also have more detailed explanation documents.
2Writing modular code
Good PHP code should be modular. PHP's object-oriented programming features are some particularly powerful tools that can break down your application into functions or methods. You should try to separate as much of your application's server-side HTML from the frontend as possible./CSS/JavaScript code, you can also follow MVC (Model-View-Controller) on any PHP framework.-View-Controller) pattern.
3Coding standards
Good PHP code should have a complete set of coding standards. By naming variables and functions, using unified methods to access databases, handling errors, and the same code indentation style, you can achieve programming standards, making your code more readable.
4Write portable code
Good PHP code should be portable. You can use existing features of php, such as magic quotes and short tags. Try to understand your needs, and then write code that is independent and portable by adapting to PHP features.
5Write secure code
Good PHP code should be secure. PHP5Provides excellent performance and flexibility. However, the security issue is entirely up to the developer. For a professional PHP developer, it is crucial to have a deep understanding of major security vulnerabilities, such as: cross-site scripting (XSS), cross-site request forgery (CSRF), code injection vulnerabilities, character encoding vulnerabilities. By using PHP's special features and functions, such as mysql_real_escape_string, etc., you can write secure code.
6Code comments
Code comments are an important part of code. Through code comments, you can understand what the variable or function does, which will be very useful in code maintenance in the future.
7Use single quotes instead of double quotes
Always use single quotes instead of double quotes for strings to avoid performance degradation caused by PHP searching for variables within strings. Using single quotes to include strings will be faster because PHP will search for variables within strings enclosed by double quotes, but not in single quotes
8Escape string output
Pass ENT_QUOTES as a parameter to the htmlspecialchars function to ensure that single quotes (')' are also converted to HTML entities, which is a good habit.
9Output strings separated by commas
Outputting strings separated by commas (,) using echo statements is more performant than using string concatenation operators (.)
10Check the value passed before outputting
Check the value passed in $_GET['query'] before outputting. You can use the isset or empty function to check if the variable is a null value.
That's all for this article, I hope it helps with your learning, and I also hope you will support the Yell Tutorial more.