Penn State

Web Conference 2005

Writing PHP for ITS/ASET Web services

Your First PHP Script

<- Back - Penn State Specifics|Up |The PHP Language - Next ->

Your first PHP script

  1. Connect to your Web space.

  2. Begin by opening a text editor such as Notepad and write the following content (copy/paste into your editor):


    <html>
    <body>
    <p>This is a simple Web page.</p>
    </body>
    </html>
  3. Next, save this content as a new file called firstphp.html in the phpclass sub-folder of your Web space.

  4. Now, rename the file in to be firstphp.php and view it as http://www.personal.psu.edu/x/y/xyz123/firstphp.php. It should look the same, however you may notice the server name in the URL automatically changed from www.personal.psu.edu to php.scripts.psu.edu.

  5. So we have seen PHP (.php) pages are really just specialized HTML (.html) pages. Let's add some dynamic content. Edit firstphp.php to appear as follows:


    <html>
    <body>
    <p>This is a simple Web page.</p>
    <b><?php echo "<p>With a little PHP</p>\n"?></b>
    </body>
    </html>

    View the page again. It should have the two lines written above. Now look at the source HTML of the file (how to view source). You should see how the second paragraph has been added, but you don't see the "php" or "echo" text.

Let's examine the php code:

<- Back - Penn State Specifics|Up |The PHP Language - Next ->

If you have any questions, feel free to ask me.

Content by: Jeff D'Angelo <jcd@psu.edu> © 2005

See the source for this page

Last update on: Sat Jun 11, 2005, 8:20:31 PM