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.
For this exercise, your task is to write a PHP program that outputs “Hello world!”.
Hello world!
- Submission will be tested on PHP7.2.
- Filename must be
exer1-hello-world.php
Gist: https://gist.github.com/czarpino/155c2a54698aca740b6283ca96e3bedd