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
//PHP code here
?>

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

Example

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

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.