Example PHP Script
Here's a simple example of a PHP script that prints "Hello, World!"
to the browser:
<!DOCTYPE html>
<html>
<head>
<title>PHP Example</title>
</head>
<body>
<?php
// PHP code goes here
echo "Hello, World!";
?>
</body>
</html>
To run this script, save it with a .php
extension, for example, example.php
. Then, you can place it in a web server's root directory (e.g., htdocs
in XAMPP
or www
in WAMP
), and access it through your web browser by typing something like http://localhost/example.php
in the address bar.
When you open the URL, you should see the message "Hello, World!"
displayed in your browser. This is a classic introductory script that demonstrates the basic syntax of PHP and how to output content to a web page.