In my previous post, you had learned how to How to write good PHP Code . In this post I have explained how to comment your PHP Code
Why You Should Comment Your PHP Code:
Code commenting is a code that is not executed or read as part of the program. The code comments are used to make code more readable and easy to understand. The code with proper comments considered as good programming that let’s other programmers to understand what you are doing in each step. Actually when you are working with a group of peaple then it is necessary to use proper code comments to share code with them.
Good Code commenting also helps you to remind what you did previously. comments can remind you about functons, methods and helps to editing the code.
How to comment your PHP Code:
You can commnet your php code by using double forward slash “//”
You can use hash “#” to comments your php code when it is ingle line
You can also comments your php code by using “/* */” . This useful becuase, by using this you can comments several lines of code block.
- echo “my php code comments example”;
- /*echo ”my php code comments example1″;
- echo ”my php code comments example2″;
- echo ”my php code comments example3″;
- echo ”my php code comments example4″;*/
You can also describe functions or method inside this “/* */”
- This function is written for printing message.
- you just pass message argument.
- function printMessage($message)
- echo $message;