In this post, we will learn how to write comments in PHP. PHP comments are written in PHP block to explain the working of code. Generally it describe the functionality of PHP code. PHP comments are not seen in output. They are ignored by the PHP compiler.

How To Write Comments in PHP ?

Write Comments in PHP

There are two types of PHP comments. Which are as follows:

1. Single Line PHP Comment

This Comment start with // (Double Forward Slash). In the example below it is used for comment:

<?php
// This code prints CodexRadar as output
echo "CodexRadar";
?> code-box


2. Multi Line PHP Comment

This Comment start with /* and ends with */ . PHP multi line comment same as the CSS comment so don't be confused between these. In the example below it is used for comment:

<?php
/* This code prints CodexRadar
as output */
echo "CodexRadar";
?> code-box


Summary

In this post we learned how to write comments in PHP. You try to make it yourself. I hope you make. If you face any problem, then comment and tell us. Keep visiting the blog to read more similar posts.

Post a Comment

Previous Post Next Post