PHP scripts begin with the opening tag <?php. Everything after that tag is PHP until the file ends or you close with ?>. For pure PHP files, omit the closing tag so trailing whitespace cannot leak into output.
PHP · Lesson 1 · On the house
Hello, PHP
<?php, echo, .php files, CLI. Lesson 1 is free — on the house.
Lessons · PHP · Lesson 1 of 10 · On the house
Hello, PHP
<?php, echo, .php files, CLI.

echo sends text to standard output. echo "hello\n"; prints hello and a newline. Statements end with a semicolon. Double-quoted strings interpolate variables later; for a fixed literal, either quote style works.
Save source as a .php file. From a terminal with PHP installed, run php hello.php to execute on the CLI without a web server. The same file can later run under Apache, nginx+php-fpm, or the built-in server.
php -v prints the engine version. PHP 8.x is the modern introductory target: named arguments and better errors exist, but this track stays on core syntax first.
Misses: writing print("hello") as if it were Python's print with required parentheses style only, forgetting <?php, saving as .html with no engine, or using console.log from JavaScript.
hello
<?php
echo "hello\n";Quiz
What opening tag starts PHP code?
Quiz
Which statement writes text to output?
Quiz
How do you run a PHP file from the CLI?
Quiz
What file extension do PHP scripts normally use?
Check
Match the still for: Hello, PHP.
Open-book: the answers are on this page. Pass every quiz and check (5) to mark the lesson done. This visit: 0/5.