WE Lab 12
WE Lab 12
Class: BESE-9AB
Introduction:
PHP is a widely used server side scripting language for web development. During lectures,
students have learned the syntax and basic concepts of PHP. Students have also learned basic
PHP concepts of functions, control structures, conditional statements, arrays etc. Students will
practically get in-depth practical knowledge of the basic PHP concepts in this lab.
Lab Objectives:
The objective of this lab is helping students to familiarize themselves with the usage of PHP to
control dynamic and server side behavior of a web site. Students will develop small PHP
applications according to the given scenarios. The knowledge students have gained in the
lectures will help them to understand syntax of PHP.
Tools:
Notepad, DreamWeaver, browser.
Helping Material:
Lecture slides.
W3Schools: https://www.w3schools.com/php/
PHP: www.php.net
Lab Task
Task 1
Note: In the supporting material compressed file (see ‘lab-11-supporting-material.zip’), a
skeleton file is given which includes basic skeleton (‘task-1-skeleton.php’) for this task.
Write a PHP script to calculate and display average temperature, seven lowest and highest
temperatures as shown in figure below. The temperatures array is already created and
initialized in the skeleton script. (hint: php sort() function can be used to sort an array)
Write a PHP script that creates the following table using for loops
Task 3
Note: In the supporting material compressed file (see ‘lab-11-supporting-material.zip’), a
skeleton file is given which includes basic skeleton (‘task-3-skeleton.php’) for this task.
Write a PHP script using nested for loop that creates a chess board as shown below. (Hint: the
chess board is an 8x8 table. Use ‘bgcolor’ property of each cell to make it black or white).
Solution
Task 1:
Task 1 screenshot:
Task 2:
Task 2 screenshot:
Task 3:
Task 3 screenshot:
Deliverables
Compile a single word document by filling in the solution part and submit this Word file on LMS.
You must include your name, ID, and class on first page. The lab grading policy is as follows: The
lab is graded between 0 to 10 marks. For some of the labs, students have to present their
solutions in a viva session. In case of any problems with submissions on LMS, you should
contact your lab engineer Mr. Aftab Hussain by email at [email protected].