start here

Introduction

PHP is a programming language commonly used to build web applications, APIs, command-line tools, background workers, and maintenance scripts. A PHP program can be a single file or part of a much larger application.

This first track starts with small command-line scripts. Running a file in the terminal gives you a quick feedback loop: edit the file, run it, read the result, and fix mistakes. The same language is used later when PHP handles a web request.

Check the installed runtime:

php --version

The first line names the PHP version. This course targets PHP 8.5.6, but professional work often involves reading older code and planning upgrades carefully.

You can also run a short instruction without creating a file:

php -r 'echo PHP_VERSION, PHP_EOL;'

PHP_VERSION is a built-in constant containing the runtime version. PHP_EOL prints the platform's normal line ending.

If the terminal reports that php is not found, install PHP CLI or check that its executable is on your PATH before continuing.

Practice

Check Your PHP Version

Run php --version. Write down the PHP version shown on the first line.

Show solution
php --version

The exact output depends on the installed runtime. Confirm that the command succeeds and that you can identify the version number on the first line.

Print The Runtime Version
php -r 'echo PHP_VERSION, PHP_EOL;'
Show solution

The command prints the installed PHP version followed by a newline. PHP_VERSION is a built-in constant, and PHP_EOL supplies the line ending.

Check Whether PHP CLI Is Available
Show solution

Confirm that PHP CLI is installed, then check whether its executable is available on the shell's PATH. On systems with multiple PHP versions, also confirm that the php command points to the intended runtime.