PHP Syntax

PHP Syntax

A PHP script is executed on the server, and the plain HTML result is sent back to the browser.

Basic PHP Syntax

A PHP script can be placed anywhere in an HTML document. Every PHP script starts with <?php and ends with ?>:

Example

<?php
// PHP code goes here
echo "Hello World!";
?>

The default file extension for PHP files is .php. A PHP file normally contains HTML tags, along with some embedded PHP scripting code.

PHP Case Sensitivity

In PHP, keywords (e.g., if, else, while, echo, etc.), classes, and functions are NOT case-sensitive. However, all variable names are case-sensitive!


Exercise

?

How do you start a PHP block of code?