MMDT1146 PHP Programming
Week 2


Week 2

General Notes:

  • Use an organizational system for the work you are putting on your server space.
    I have suggest something like lab1, lab2, and so on.
  • Create an index.htm file that points to each lab.  I should be able to open your web site and be able to navigate to all parts of your lab assignment.  Look at past examples to get ideas. 

Review HTML concepts.

To test if php is running, use this script:

<?php
phpinfo()
?>

The quickest way to display all php errors and warnings is to add these lines to your PHP code file:

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>


Lab 2

This lab is to test your knowledge of being able to intersperse PHP code within HTML code.

Create a subfolder on your webserver named "lab2".  (This may already be done for you from doing the in class exercises.)

Under the subfolder "lab2" that you just created, create the file "lab2.php".

"lab2.php" must contain several items.  Your resulting output should like similar to this.

Title your page.
Put a caption on the top of your page.
Add a background.

Create a table, or div layouts, of at least two cells in size.

In the top cell:
Create a PHP script. Create two variables. $firstname and $lastname.
Create a 3rd variable $fullname that is the concatanation of $firstname and $lastname.
Echo $fullname to the screen.
Print out the IP address of the user viewing your page. Hint: $_SERVER['REMOTE_ADDR']

In the bottom cell:
Create a second PHP script.
Define a constant named PI.
Create a variable $radius with a value of 250 or larger.
Create a variable $circumference and do the calculations where
circumference is equal to 2 times PI times r.
Create a variable $area and do the calculations where
area is equal to PI times r squared.

Echo the calculations to the screen and format the numbers so that there is a comma in the thousands place and there is only one digit after the decimal point.

Echo your value of PI to the screen.

Assignment is due 1 week from when it was assigned.  50% penalty if late.

MMDT 1146 Lab 2
Grading Criteria
Date:
Possible
Points
15
Your
Points
15
Page is titled, captioned, and has a background. 1 1
At least a two cell table is created. 2 2
Top cell contains PHP script that meets the requirements as stated earlier. 5 5
Bottom cell contains PHP script that meets the requirements as stated above. 5 5
Page validates to W3C standards. (Check using W3C online validator) 2 2