Skip to content

Instantly share code, notes, and snippets.

@czarpino
Last active September 18, 2020 08:38
Show Gist options
  • Save czarpino/155c2a54698aca740b6283ca96e3bedd to your computer and use it in GitHub Desktop.
Save czarpino/155c2a54698aca740b6283ca96e3bedd to your computer and use it in GitHub Desktop.

Hello World

A journey of a thousand lines begins with a “Hello world!”. - Czar

This exercise aims to introduce you to PHP via the customary "Hello world!".

Unlike most programming languages, PHP is a scripting language originally design as a templating language for C. This is why it can easily embedded HTML codes. On the other hand, this has resulted in PHP having quite a unique syntax as compared to most other languages. For example, a PHP script must always start with <?php. Anything outside the opening and closing PHP tags then become treated as output (usually HTML).

Here is how PHP mixed with HTML looks like:

<h1><?php echo "Hello world!"; ?></h1>

And, here is how a PHP only program looks like

<?php

echo "Hello world!";

When writing a program in PHP, the program file must have file extension .php. Sometimes, however, certain software written in PHP may omit the .php extension but in most cases it is best to have it so we know we are dealing with a PHP program.

Exercise

For this exercise, your task is to write a PHP program that outputs “Hello world!”.

Output

Hello world!

Testing and Submission

  • Submission will be tested on PHP7.2.
  • Filename must be exer1-hello-world.php

Gist: https://gist.github.com/czarpino/155c2a54698aca740b6283ca96e3bedd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment