Your first PHP-enabled page
Create a file named hello.php and put it in your web server's
root directory (DOCUMENT_ROOT) with the following content:
Example 2-1. Our first PHP script: hello.php
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
Use your browser to access the file with your web server's
URL, ending with the "/hello.php" file reference.
When developing locally this URL will be something like
http://localhost/hello.php or http://127.0.0.1/hello.php
but this depends on the web server's configuration. Although
this is outside the scope of this tutorial, see also the
DocumentRoot and ServerName directives in your web server's
configuration file (for Apache, this is httpd.conf). If
everything is configured correctly, this file will be parsed
by PHP and the following output will be sent to your browser:
|