# Your first PHP-enabled page

This tutorial assumes PHP is already installed. Installation instructions can be found on the » download page.

Create a file named hello.php with the following content:

Example #1 Our first PHP script: hello.php

`<?php
echo "Hello World!";
?>`

Using your terminal, navigate to the directory containing this file and start a development server with the following command:

    php -S localhost:8000

Use your browser to access the file with your web server's URL, ending with the `/hello.php` file reference. According to the previous command executed, the URL will be `http://localhost:8000/hello.php`. If everything is configured correctly, this file will be parsed by PHP and you will see the "Hello World!" output displayed in your browser.

PHP can be embedded within a normal HTML web page. That means inside your HTML document you can write the PHP statements, as demonstrated in the following example:

`<!DOCTYPE html>
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>`

This will result in the following output:

    <!DOCTYPE html>
    <html>
        <head>
            <title>PHP Test</title>
        </head>
        <body>
            <p>Hello World</p>
        </body>
    </html>

This program is extremely simple and you really did not need to use PHP to create a page like this. All it does is display: `Hello World` using the PHP echo statement. Note that the file does not need to be executable or special in any way. The server finds out that this file needs to be interpreted by PHP because you used the ".php" extension, which the server is configured to pass on to PHP. Think of this as a normal HTML file which happens to have a set of special tags available to you that do a lot of interesting things.

The point of the example is to show the special PHP tag format. In this example we used `<?php` to indicate the start of a PHP tag. Then we put the PHP statement and left PHP mode by adding the closing tag, `?>`. You may jump in and out of PHP mode in an HTML file like this anywhere you want. For more details, read the manual section on the basic PHP syntax.

> Note: A Note on Line Feeds

> Line feeds have little meaning in HTML, however it is still a good idea to make your HTML look nice and clean by putting line feeds in. A linefeed that follows immediately after a closing `?>` will be removed by PHP. This can be extremely useful when you are putting in many blocks of PHP or include files containing PHP that aren't supposed to output anything. At the same time it can be a bit confusing. You can put a space after the closing `?>` to force a space and a line feed to be output, or you can put an explicit line feed in the last echo/print from within your PHP block.

> Note: A Note on Text Editors

> There are many text editors and Integrated Development Environments (IDEs) that you can use to create, edit and manage PHP files. A partial list of these tools is maintained at » PHP Editors List. If you wish to recommend an editor, please visit the above page and ask the page maintainer to add the editor to the list. Having an editor with syntax highlighting can be helpful.

> Note: A Note on Word Processors

> Word processors such as StarOffice Writer, Microsoft Word and Abiword are not optimal for editing PHP files. If you wish to use one for this test script, you must ensure that you save the file as plain text or PHP will not be able to read and execute the script.

Now that you have successfully created a working PHP script, it is time to create the most famous PHP script! Make a call to the phpinfo() function and you will see a lot of useful information about your system and setup such as available predefined variables, loaded PHP modules, and configuration settings. Take some time and review this important information.

Example #2 Get system information from PHP

`<?php
phpinfo();
?>`
`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open