PHP Syntax

A PHP script starts with the <?php and ends with the ?> tag. These tags tells the PHP engine to treat the enclosed code block as PHP code, rather than simple HTML. PHP files are plain text files with .php extension. A PHP file can contain HTML, JavaScript as well as PHP scripts for server side execution. All PHP statements end with a semicolon (;).

PHP Syntax

//PHP code here

Following PHP script uses a built-in PHP function “echo” to print “Hello World!” on a web page.


<!DOCTYPE html>
<html lang=”en”>
<title>PHP Hello World</title>
<h1><?php echo “Hello World!”; ?></h1>

PHP Case Sensitivity

The variable names in PHP are case-sensitive which mean $name, $Name, and $NAME are three different variables. However the keywords (e.g. if, else, print, while etc.), function and class names are case-insensitive. As a result calling the print or PRINT produce the same result.