PHP: Comments

Read Time:46 Second

In addition to code, source code files may contain comments. This is text that is not part of the program and is needed by programmers for notes. They are used to add explanations of how the code works, what errors need to be fixed or something to remember to add later.

Comments in PHP come in two flavors:

Single-line comments

Single-line comments begin with //. These characters can be followed by any text, the whole line will not be parsed and executed.

Comments can take up an entire line. If one line is not enough, several comments are created:

<?php

// For Winterfell!
// For Lanisters!

The comment may be on a line after some code:

Multi-line comments

Multiline comments begin with /* and end with */. In between each line must begin with a *.

<?php
/*
 * The night is dark and
 * full of terrors.
 */
print_r('I am the King');
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published.

Previous post Typical tasks for a React-developer
Next post Python: Strong (or Strict) Typing