Writing comments while doing codding is good practice. It helps other developers to understand your code. There are three ways of using the php comments.

// – The two backlash “//” indicates the code written after the backlash cannot be executed in the php file. The browser will ignore the code mention after the backlashes.

# – The hash “#” indicates the code mention after the hash is the comment. It will not run in the browser and simply neglected.

/* text */ – The slash and asterisk sign are used to mention the long line comment. Sometimes developer uses the complete sentence or paragraph to describe the code they are using for a particular function to run. This comment format allows the developer to write a long comment in a paragraph.

Example of php comment:

<?php

// This line will be ignored by browsers.

# The hash indicate do not run the text.

/*
This is useful for long paragraph comment
as you want to provide more information
to describe the code.
*/

?>

Related Posts

Leave a Reply