Hello, World
A PHP script starts with <?php; print with echo.
Runs in Zerethon IDE · PHP 8.4
Official PHP documentation ↗
main.php
<?php
echo "Hello, World!\n";
echo 'Sum: ' . (2 + 3) . PHP_EOL;
printf("%s has %d letters\n", 'PHP', 3);
Output
Hello, World! Sum: 5 PHP has 3 letters
- Here PHP runs on the command line (CLI), not in a web server: output goes to the Output tab, there is no browser,
$_GETor HTML page. echodoes not add a newline — end with"\n"orPHP_EOL.- Join strings with
., not+. Double quotes expand variables and\n; single quotes do not. - A file with only PHP code needs no closing
?>.