0% complete

PHP Introduction · Lesson 5 of 7

Your First PHP Program

Write and run a small PHP script.

Lesson

PHP tags mark where PHP code starts and ends inside a file. A PHP-only file commonly begins with

Code examples

Your first PHP script
PHP
echo "Hello, PHP!";
Expected output
Hello, PHP!

Key points

  • Start PHP code with the <?php opening tag.
  • echo writes output; it does not itself run a script.
  • Run the file with PHP CLI or request it from a PHP-enabled server.

Your learning progress

Finish this lesson

Optional practice

PHP playground

This site does not execute learner-provided PHP code. Connect a secured PHP sandbox service before enabling code execution.

Execution is disabled. No code is sent to a server.