Comments in PHP code are lines that are not executed as part of the program. Its sole purpose is to be read by someone reviewing the code.

Comment lines can be used to:

  • For others to understand your code
  • To remind yourself of what you're doing. Many programmers have experienced returning to their own jobs after a year or two and having to re-understand what they were doing. Comments can remind you what you were thinking when you wrote the code.

PHP Comments

PHP supports 3 different comment lines.

  • Single comment line with //
  • single comment line with #
  • Multiple comment lines with /* */

Now let's reinforce these with examples.

// Bu bir tekli yorum satırıdır
# Bu bir tekli yorum satırıdır
/* 
 * Bu bir çoklu yorum satırıdır
 * Bu bir çoklu yorum satırıdır
 */

PHP Single Comment Line and Multiple Comment Line Differences

Single comment lines must be a single line and have no closure. // or # is used only to indicate that there is a comment line at the beginning. Multiple comment lines must start with /* and end with */.

Single comment line is used in short comments, while multiple comment line is used in long comments requiring more than one line.