Web development students that are just starting out often overlook the usage of comments in PHP. It's rather unfortunate, since using comments actually saves more time in the long run, although new students only see the short-term benefits and thus don't make use of them. Such students should take heed to this advice, since it's often even required my employers.
Comments aren't parsed by the PHP engine, so they are only visible to those who are viewing the original source code of the file. This is great for documenting what each code block does, all while keeping the casual visitor to a website oblivious to the extra comments present on the application they are using.
It's often a better idea to use PHP comments in place of others such as HTML comments, since PHP comments will never be seen by the end user if the script is running correctly. This simple fact will help safeguard against others stealing source code, ideas, or principles from an application.
There are actually three operators that we may use to tell the PHP engine that we want to use a comment. Single inline comments can be used with the "//" and "#" operators. For multiple-line comments, we use "/*" and "*/" respectively to indicate what is a comment and what is actually PHP code. While the first two operators are synonymous, the last one discussed is the only one that can perform multiple line comments with relatively little work.
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.
In Conclusion
In the end, there is a lot to gain from using PHP comments. They are quite functional for saving time, and also serve their purpose in troubleshooting. For more information on the idea of using comments effectively, check out local bookstores and online resources for more material. - 16039
Comments aren't parsed by the PHP engine, so they are only visible to those who are viewing the original source code of the file. This is great for documenting what each code block does, all while keeping the casual visitor to a website oblivious to the extra comments present on the application they are using.
It's often a better idea to use PHP comments in place of others such as HTML comments, since PHP comments will never be seen by the end user if the script is running correctly. This simple fact will help safeguard against others stealing source code, ideas, or principles from an application.
There are actually three operators that we may use to tell the PHP engine that we want to use a comment. Single inline comments can be used with the "//" and "#" operators. For multiple-line comments, we use "/*" and "*/" respectively to indicate what is a comment and what is actually PHP code. While the first two operators are synonymous, the last one discussed is the only one that can perform multiple line comments with relatively little work.
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.
In Conclusion
In the end, there is a lot to gain from using PHP comments. They are quite functional for saving time, and also serve their purpose in troubleshooting. For more information on the idea of using comments effectively, check out local bookstores and online resources for more material. - 16039