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:

        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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.