DONATE Hyvor Developer
PHP
PHP TUTORIALPHP IntroductionPHP InstallationPHP Hello WorldPHP Basic SyntaxPHP CommentsPHP VariablesPHP Variable ScopePHP ConstantsPHP OutputPHP Data TypesPHP Type CastingPHP OperatorsPHP ConditionalsPHP Shorthand ConditionalsPHP LoopsPHP Loop Control StructuresPHP FunctionsPHP StringsPHP ArraysPHP Superglobal VariablesPHP in HTMLPHP RegexRegex IntroductionRegex PCRE SyntaxPHP PREG FunctionsPHP FormsPHP Forms IntroductionPHP Forms CreatingPHP Forms SecurityPHP Forms ValidationPHP Forms Required InputsPHP Forms StickyPHP Forms Advanced ValidationPHP Forms Finishing

PHP Comments

Good programmers write perfect code with plenty of comments.

  • Comments are used to understand the code while reading.
  • They can also be used to leave a part from the code.
  • Comments are really important when trying to understand other's or your own code after years.
  • Comments can explain what the code does.
  • Comments does not need to follow language syntax rules.

PHP parser ignores all the comments.

There are two ways of commenting

  • Single-Line Commenting - // your comment or # your comment
  • Multi-Line Commenting - /* your comment */

PHP Comments Example


<?php

// this is a single-line comment

# this is a single-line comment too

/*
	This is a multi-line comment
	This line is a comment
*/

// to remove a part of code
echo 5 /* + 2 */  + 5;

Run Example ››
0
58