Posts Learn Components Snippets Categories Tags Tools About

PHP Comments

Learn how to define comments in PHP to document your code.

Created on Jun 15, 2021


There are 3 ways to define comments in PHP. The purpose of having comments is to describe/document the code so that anyone reading the comments can further understand your intention.

Defining Single-line Comments
// Single-line comments
or the other syntax would be
# Alternative way to define single line comments

Defining Multi-line Comments
    Multi-line comments
    It can span into multiple lines

Code Example

Created by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for PHP Comments

PHP Basics cover

PHP Basics

Learn the basics of PHP language and get a firm foundation of the features and functionalities