To gain a basic understanding of the structure of a programming language, one usually creates a small program displaying Hello world! on the screen. To do so create the file example.php with the following content:
<?php
echo "Hello World!";
?>
The file extension php tells the web server to load the file with the PHP interpreter. Each PHP command block starts with a <?php and finishes with a ?>. The line breaks are not required but help to keep a structured overview. Everything between <?php and ?> is interpreted by PHP, everything outside the block will be interpreted as normal HTML. This allows easy use of HTML elements within PHP files with little effort.
Here is a more extensive example:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello world! - Example</title>
</head>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>
In this example a complete HTML page with DOCTYPE, title and body is created and Hello world! is displayed through PHP within the <body> element.