Hello World in PHP

Our first program will print the classic “hello world” message. Here’s the full source code.

<?php
echo "hello world";
?>

To run the program, save the code in a file called hello-world.php and use the php command to execute it.

$ php hello-world.php
hello world

In PHP, scripts are usually not compiled into binaries like in some other programming languages. Instead, PHP is interpreted, meaning the PHP engine parses and executes the script directly.

We’ve successfully run a basic PHP script that outputs “hello world”. Let’s learn more about the language.