On this blog page, you will learn the basic PHP Syntax, Comments in PHP.
PHP Syntax With Example
1 2 3 4 | <?php // Starting Tag ?> // Closing Tag |
However, if a file contains only PHP code, the enclosing tag is optional
PHP Syntax with Code
1 2 3 | <?php echo $freeonlinetest; ?> // Code End with Semicolon In PHP |
PHP Comments with Example
PHP supports two types of comments:
- One-line comments
- Multi-line comments
One-line Comments
A one-line comment starts with the pound (
#
) or double forward-slash (//
) In PHP. The one-line comment is placed at the starting of the line or at the current block.Example:
1 2 3 4 | <?php // Here is the Code for the Addition $sum = $a + $b; ?> |
Multi-line Comments
A Multi-line comment starts with
/*
and end with */
in PHP.Example:
1 2 3 4 5 6 7 | <?php /* This is an example of a multi-line comment in PHP, PHP script will avoid those lines. */ ?> |
What is the importance of Comments in PHP.
In PHP Comments are important parts of the code because they explain the purpose of the code or what is the logic written in this code or what the code does. So it makes a programmer more readable.