Your First PHP Script

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.php

For a browser response, use an HTML document and escape any untrusted value with htmlspecialchars(). Keep configuration and credentials outside the public document root.

admin

admin

Leave a Reply

Your email address will not be published.