3.1. Getting Started

In this section you learn to write simple applications. The basics of PHP's interpreter are also covered in detail.

3.1.1. “Hello World”

The first application you will find in most books about computer programming is “Hello World”. “Hello World” is easy to implement in all languages because it does nothing except print a string on the screen, so it is a good start. Here is the easiest version of “Hello World” written in PHP:

<?php
        echo 'hello world<br>';
?>

With just three lines of code, you can print a simple message on the screen. The first line of code tells the Web server that the next lines of code have to be executed by the PHP interpreter. ?> means that the code ends here. Using <?php is not the only possible way ...

Get PHP and PostgreSQL: Advanced Web Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.