« Hello world in php
Data Types in PHP »


How to put comments in php

Posted by chaabant on Dec 26, 2007

In php there are different ways to put comments , comments are very important .

Importance of php Comments in programming:

  • It’s a Good Practice
  • It saves a lot of time , you won’t need to read your code to understand what it does
  • Make your code understandable for others, so that if many programmers are working on a same project, or when your boss fires you, it would be helpful for then next programmer to understand what you have done.

Any code that took thought to write will take thought to reread after several days, months or in some cases, years.

Ok , now let’s go back to How to put comments in php …

  1. // Single line comment
  2.  
  3.  
  4. # Single line comment
  5.  
  6.  
  7.  
  8. /* Multi-line
  9. Line 1
  10. Line 2
  11. Line 3
  12. */
  13.  
  14.  
  15.  
  16. /**
  17. * API Documentation Example
  18. *
  19. * @param string $bar
  20. */
  21.  
  22. function foo($bar) { } //code
Leave a Reply

You must be logged in to post a comment.