Last updated: August 26, 2026.
Create a file named hello.php, run it with the PHP command-line interpreter, or place it under a configured web server document root.
Hello-world script
<?php
declare(strict_types=1);
$name = 'WebCheatSheet';
echo "Hello, {$name}!
";Run it from a terminal
php hello.phpFor a browser response, use an HTML document and escape any untrusted value with htmlspecialchars(). Keep configuration and credentials outside the public document root.