Originally published on zero2php.dev — part of the Zero to PHP course. View this lesson on the original site.

Opening tag

Executable PHP normally starts with <?php. Use the full tag in files you save—short tags depend on configuration.

Statements and semicolons

Statements are instructions that do something; many end with a ;. Missing semicolons cause parse errors: PHP stops before running your logic.

Pure PHP files usually omit the closing ?> at the end of the file. Accidental whitespace after ?> has caused real bugs with HTTP headers later; omitting the close tag is normal.

Minimal example

<?php

declare(strict_types=1);

$x = 1;
echo $x, "\n";

When something breaks

If PHP prints a parse error, read the file name and line it reports—fix that line first.

Exercise

Use the code checker below. Print exactly ok (two lowercase letters, no extra output).

From Zero to PHP — PHP foundations: environment, syntax, and values