Standard PHP Syntax

You can insert the PHP code in between of your HTML code. An extension of a PHP file is “.php”.  We can start out PHP code using “<?php” and in the end “?>” (Please ignore double quotes).

Just look this example that shows how we can insert the PHP code in between of HTML Code.

Hello.php

						
 <html> 
 <head> 
 <title>Hello World</title> 
 </head> 
 <body> 
 <?php 
 echo ‘This is my first dynamic line of PHP’; 
 ?> 
 </body> 
 </html>						

Output:

This is my first dynamic line of PHP.

Remember Always: PHP statements always end with a semi-colon.

PHP Comments

Comments are generally use by the programmers itself for make the code easily understandable for future corrections, optimizations and maintenance.
In the large web applications like e-commercial application, the PHP developers make the comment for their developed PHP code. These comments can represent what the particular code is doing? And what is the flow of that PHP code?

Hello.php

						
 <html> 
 <head> 
 <title>Hello World</title> 
 </head> 
 <body> 
 <?php 
 //This is the single line comment
echo 'This is my first dynamic line of PHP';    
/*
This is the multiline comment
@Author Javatportal.com
echo 'This is the second echo statement of this code';
*/
 ?> 
 </body> 
 </html>						

Output:

This is my first dynamic line of PHP

The above code will not execute the second echo statement because that statement we mentioned in comments section and comment section does not execute anything

PHP Case Sensitivity

Of course PHP is not fully case-sensitive scripting language but the variables name are case sensitive. Just look these following examples.

CaseSensDemo.php

						
 <html> 
 <head> 
 <title>Hello World</title> 
 </head> 
 <body> 
 <?php 
 $age=22;
echo 'My age is '.  $Age . "
						

Output:

My age is
My age is
My age is 22

In the above examples the variables $age, $Age and $AGE considered as three different variables and all echo statements will print because the keywords, functions, object, classes are not case sensitive.


Next Concept PHP Variables