Back to DFS's Workshop Page
Back to Agenda 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 to create a web page on the fly. Follow the simple steps below.

  1. Type

    cd
    to get to your home directory.

  2. Type

    cd public_html/test_php
    to descend into your php script directory.

  3. Edit the file called helloworld.php so that it looks like the following code.

    <!-- 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>
    
  4. In your favorite web browser, type

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

Notes


© 2002-2004 DFStermole
Created: 22 Sept 02
Last Modified: 7 July 04