Back to DFS's PHP Page


Your Second Script

Your second script, as did the first, will generate the traditional "Hello, World!" greeting. However, this time you will use a combination of PHP along with HTML. Follow the simple steps below.

  1. Type

    cd
    to get to your home directory.

  2. Type

    cd public_html
    to descend into your web pages directory.

  3. Create a new file called hello_world.php.

  4. Type in the following lines:

    <!-- helloworld.php
      This file illustrates how to embed PHP code inside HTML
    -->
    <html>
    <head>
    <title>PHP inside HTML: Hello World</title>
    </head>
    <body>
    <?php
    echo "<h1 align=\"center\">The Hello World Program Output</h1>\n";
    // Print the message
    echo "<p>Hello, World!\n";
    ?>
    <body>
    <html>
    
  5. In your favorite web browser, type

    http://localhost/~YOURID/helloworld.php
    where YOURID is the user ID you have on the system.

Notes


© DFStermole: 2002
Created: 22 Sept 02
Last Modified: 22 Sept 02