PHP Tutorial
Creating a webpage using PHP is very simple. PHP-enabled pages can be created and edited
the same way as your regular HTML pages but you will save your file as a .php
file rather than an .html file. The following steps need to be done before you can create
a webpage in our environment. This tutorial also explains the creation of a simple PHP page.
You will need to be familiar with basic UNIX commands in order to understand the following
instructions. If not, take a look at the manual pages for the following commands:
ls, mkdir, chmod. Use the "man" command to read a man page.
Create your .www directory
The first step is to check the permissions on your home directory and create a .www
directory within it. Read the .www tutorial to do this.
Create your PHP script
If you have already set up a homepage as index.html, you can just rename it index.php. Otherwise
use any text editor to create your PHP code. Please note that the file you create should be in
the .www directory with the .php extension.
Cut and paste the following into the editor:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PHP Test</title>
</head>
<body>
<?php
echo '<p>Hello World</p>';
?>
</body>
</html>
Save your file as index.php. Then, from your .www directory,
execute the following command to ensure that the file permissions are correct.
% chmod 644 index.php
This will make your page viewable to users with a web browser.
Test your PHP script
Use your web browser to access the file. The URL for your script should be:
http://www-users.cs.umn.edu/~<username>/index.php http://www-users.itlabs.umn.edu/~<username>/index.php
If you get an Internal Server Error, double-check that you followed all the steps above. If you still can't
get it to work, contact Systems Staff.
Disclaimer Policy
University of Minnesota policy requires that the following disclaimer appear on all personal pages and on all student organization pages. It will be automatically appended to pages that you create:
"The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota."
Related Links
University of Minnesota Policies
The policies enforced by the U of M must be followed while creating web pages within the University's domain.
Helpful PHP links
The following list contains helpful resources for creating PHP web sites.
|