Comments in PHP language
Notes:
Comments in PHP
Comments are something like notes inside the code.
Note: Comments are ignored by the PHP engine.
Types of comments in PHP:
There are 2 types of comments in PHP
Single line comments
(// comment goes here )
(# comment goes here )
Multiline comments
(/* comment goes here */)
Single line comment:
anything written after // on the line is treated as a comment
anything written after # on the line is treated as a comment
Multiline comment:
anything written in between /* and */ is treated as a comment
Comments are used to document the source code.
Comments are used to explain code the logic, so that we can understand the code later; as well as other developers can read and understand the code easily. Comments are used to increase the readability and understandability of the source code.
If we don’t want to execute some part(s) of the code, we can comment them so that they can be ignored by the PHP engine. Comments have no effect on the execution of a program.
Example Code:
<?php
// Author : Manjunath
# DOM: 01-01-0101
/*
echo is the language construct used to display something on the browser
sequence of character enclosed in double quatations is called as string
*/
// echo "Hello World","<br/>";
/*
echo "Hello World","<br/>";
echo "Hello World","<br/>";
*/
echo "Hello PHP";
?>
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a