The most commonly used PHP tag style starts with <?php and ends with ?>
<?php // Block of PHP code ?>
If you are using short-open tags then ensure short_open_tag is enabled and set to ON in configuration file php.ini.
<? // Block of PHP code ?>
Comments are used to describe the code, which is only intended to be read by human beings. Comments do not get compiled or executed. The purpose of comments is to help others understand or remind you later what has been implemented and the purpose of the block of code. There are two types of comments in PHP
<?php // This is an example of single-line comment. /* This is an example of multi-line comment Which covers multiple lines */ ?>
Let’s look at the below example, where all the usage of echo is correct.
<?php echo "Welcome to the world of PHP<br>"; ECHO "Welcome to the world of PHP<br>"; eCHo "Welcome to the world of PHP<br>"; ?>
Now, in the below example, variable name is case-sensitive and displays the value of first echo statement only.
<?php $KH_Name = "John"; echo "My name is " . $KH_Name . "<br>"; // Output: My name is John echo "My name is " . $KH_NAME . "<br>"; // Output: Notice: Undefined variable: KH_NAME echo "My name is " . $kh_name . "<br>"; // Output: Notice: Undefined variable: kh_name ?>
In PHP, any statement which is an expression, is terminated by semicolon (;). In the above example, each echo statement is terminated with a semicolon.