Contenu du cours
Module 1 — Discovering PHP
Understand what PHP is, set up a local environment and write your first script.
0/4
Module 3 — Functions, arrays and forms
Create functions, work with arrays and handle data coming from a form.
0/4
PHP for beginners

Let’s write our very first PHP program. Create a file called hello.php in your local folder with this content:

The code

  • PHP code opens with <?php and closes with ?>.
  • The echo statement prints text on screen.
  • Every statement ends with a semicolon « ; ».

For example, <?php echo « Hello world! »; ?> will display the phrase « Hello world! » in the browser.

Good habits from day one

  1. Always end your statements with a semicolon.
  2. Use quotes around your text strings.
  3. Save the file as .php, not as .txt.

Now open http://localhost/hello.php: your message appears, generated by the server.

Key point: echo outputs content, and every statement ends with a semicolon. These are your first reflexes.

Prix indicatifs, convertis depuis l'euro