PHP annotations

 The application of PHP annotations is an important foundation for beginners to learn PHP . Although some small programs written in the first practice are very simple, the entire code can be easily understood at a glance, but in the future, as the technology becomes better and better, the code written The program structure is getting longer and longer, and the structure of the program is getting more and more expanded. It is inevitable that you will encounter the dilemma that you can’t understand the functions you wrote before. Of course, you may not completely understand it, but you will spend more time maintaining your PHP Code, if the entire system is co-written by multiple designers, the program without annotations will become a big trouble. It can be seen that although PHP annotations are a very simple habit, they are also a very important good habit, especially in collaboration. At work.


PHP one-line comment example
<?php
// Here is a one-line PHP comment...
// Here is a one-line PHP comment...
?>

Single-line comments can be used after a line of code. Start with two slashes "//". After the slash is the comment, the code in the comment will not be executed. The feature of the single-line comment is that it can be used for each line of code. Make comments separately, the next line of the comment can still continue to execute other PHP code.

PHP multi-line comment example
<?php
/*
... here is a multi-line PHP comment
... here is a multi-line PHP comment
... here is a multi-line PHP comment
*/

?>

PHP multi-line comments start with a slash plus an asterisk such as "/*", and end with an asterisk plus a slash such as "*/", as long as the content between the /* and */ symbols is regarded as the comment text, where PHP Code will not be executed. Multi-line comments can contain a large amount of PHP Code at one time, so it is not only used to write comments for the code. Many designers often use it to test a whole section of PHP Code, such as temporarily closing a certain Segment Code for testing or debugging.

Post a Comment

0 Comments