How To Comment In PHP Applications
Because of how PHP is structured, which is to say it is done so that anyone can use it according to their own style, developers don't have to make use of PHP comments. But the truth is, most professional web developers, if not all, stress that making use of comments in PHP is vital in keeping organization and improving readability for future use.
PHP comments may only be seen by developers, since the PHP engine doesn't pay attention to remarks declared as comments. This is quite handy for developers, who can make visible notes on their source code all while the visitor to the webpage is kept in the dark about any such comments.
The general public is allowed to view some comments such as HTML comments. PHP really shines in this example, since PHP comments aren't sent out to the browser and will not be able to be viewed if the script is running correctly. This is great for keeping code secret, as well as mental notes, ideas, and other things developers don't need competitors seeing.
Comments are created with three different calls. For comments that span two or more lines, we have to use "/*" and "*/" - and "#" or "//" for single line comments. Comments in PHP can actually be placed directly after real PHP code, above it, or below it. This leaves a lot of creativity in how developers document their code according to their style and tastes.
Unbeknown to most, PHP comments can also be used for more practical scenarios, such as troubleshooting. Expert programmers will find they have a problem with their application, and comment out different blocks of code to see what is causing the error. While it is usually in new code blocks, this method will indeed show that sometimes the problem is due to program code interacting wrong, which can in effect mean the problem is anywhere in the application.
Commenting in PHP is also great to use in selection structures, since PHP has long been known as a hard to scale language. Once files start getting big, it can be dizzying to try and remember which loops and selection structures go where, and what they do. By commenting out every closing bracket, and what it is in relation to, the problem is easily fixed. This is often mandatory for programmers who work for employers.
Closing Comments
The Internet is full of many examples of how to creatively use PHP comments. Try scouting out some websites for more information on the usage, concept, and execution of comments to get better experience with this blessing. As developers find, an early history with commenting in programming is always the best route.
PHP comments may only be seen by developers, since the PHP engine doesn't pay attention to remarks declared as comments. This is quite handy for developers, who can make visible notes on their source code all while the visitor to the webpage is kept in the dark about any such comments.
The general public is allowed to view some comments such as HTML comments. PHP really shines in this example, since PHP comments aren't sent out to the browser and will not be able to be viewed if the script is running correctly. This is great for keeping code secret, as well as mental notes, ideas, and other things developers don't need competitors seeing.
Comments are created with three different calls. For comments that span two or more lines, we have to use "/*" and "*/" - and "#" or "//" for single line comments. Comments in PHP can actually be placed directly after real PHP code, above it, or below it. This leaves a lot of creativity in how developers document their code according to their style and tastes.
Unbeknown to most, PHP comments can also be used for more practical scenarios, such as troubleshooting. Expert programmers will find they have a problem with their application, and comment out different blocks of code to see what is causing the error. While it is usually in new code blocks, this method will indeed show that sometimes the problem is due to program code interacting wrong, which can in effect mean the problem is anywhere in the application.
Commenting in PHP is also great to use in selection structures, since PHP has long been known as a hard to scale language. Once files start getting big, it can be dizzying to try and remember which loops and selection structures go where, and what they do. By commenting out every closing bracket, and what it is in relation to, the problem is easily fixed. This is often mandatory for programmers who work for employers.
Closing Comments
The Internet is full of many examples of how to creatively use PHP comments. Try scouting out some websites for more information on the usage, concept, and execution of comments to get better experience with this blessing. As developers find, an early history with commenting in programming is always the best route.