St. Name:

advertisement
St. Name: ……………………………….
St. #: ………………………………….
Philadelphia University
Lecturer(s):
Faculty of IT Department of MIS
Internal examiner:
Examination Paper
---------------------------------------------------------------------------------------
(731213) Introduction to Web Programming
Information for Candidates
This examination paper contains 4 questions totaling 20 marks.
Advices to Candidates
 Attempt all questions.
 Read all questions carefully before answering.
 Allocate the available exam time to given questions properly
 Write your answers clearly.
-------------------------------------------------------
I. Basic Notions
Objectives: the aim of the following question is to evaluate your basic knowledge.
Q1: Select the correct answer from the choices given for the following questions:
[3 marks]
1) What does PHP stand for:
a) Proccessing Homepages b) Hypertext Preprocessor c) Proccessing Hyperlinks d) None of the above
2) What will be printed on the screen after executing the following PHP code segment?
$s="1a2b3c";
$sum=$s+5;
echo $sum;
a) 6
b) 8
c) 11
d) None of the above
3) What will the value of $x be after executing the following:
$x= max(8, floor(3.3), 7, 4*2, min(9, 10, 11), rand(-9,9));
a) 10
b) 9
c) 11
Page 1 of 5
d) 8
Q2: Given the following 2 PHP pages, what is the output after calling b.php page?
Page 1: a.php
<?php
Echo "WELCOME.<BR>";
define("Y", "0");
define("y", "1");
?>
Page 2: b.php
<?php
include("a.php");
$y = 5;
$Y = 10;
echo $y++ + y;
echo "<BR>";
echo y + Y;
echo "<BR>";
echo --$Y + $y++;
echo "<BR>";
echo --$y + 2;
//echo ++Y;
$y+=2;
echo "<BR>";
echo $y + y + $Y + Y;
?>
[3 marks]
WELCOME
6
1
15
8
18
II. Familiar problem solving
Objectives: the aim of the following question is to evaluate your capabilities in solving familiar
cases.
Q3:
A) Find the errors in the below code and correct them:
<html>
<body>
CARS: <BR> Car Type:
<BR>
<form action='GET'>
BMW <input type=radio name=r1 value=BMW></BR>
FORD <input type=radio name=r2 value=FORD></BR>
HONDA <input type=radio name=r3 value=HONDA></BR>
Car Description:<BR>
<input type=textarea columns='20' rows='10'></textarea>
</BR>
</form>
<input type='submit' value= order car>
</body>
</html>
<?php
ECho $_POST['r1'];
?>
Page 2 of 5
[4 marks]
Solution:
<html>
<body>
CARS: <BR> Car Type:
<BR>
<form method='GET'>//.5mark
BMW <input type=radio name=r1 value=BMW></BR>//1mark
FORD <input type=radio name=r1 value=FORD></BR>
HONDA <input type=radio name=r1 value=HONDA></BR>
Car Description:<BR>
<textarea cols='20' rows='10'></textarea>//1mark
</BR>
<input type='submit' value= "order car">//.5mark
</form>
</body>
</html>
<?php
EcHo “Your car type is:”. $_GET['r1'];//1mark
?>
B) Show the output of the previous code (As will be shown on the browser).
Page 3 of 5
[3 marks]
III. Unfamiliar problem solving
Objectives: the aim of the following question is to evaluate your capabilities in solving unfamiliar
cases.
Q4: Write a PHP Web application that consists of 2 pages; area.html and results.php. The area.html page
contains a form that will be submitted to results.php page.
A) The first file (area.html) is as shown below:
[4 marks]
B) For the data entered in the area.html page, write a PHP program in the results.php page
that shows the area of the square or circle (depends on the user's selection).
Hint:
Square's area= L*L, // L is the square's side's length
Circle's area= pi*r*r,// r is the radius and pi=3.14
[3 marks]
Solution:
Area.html
<html>
<form action=’results.php’>
Enter a number: <input type=text name='a'>
<br><br>
Choose a shape:
<select name='ss'>
<option value="s"> square </option>
<option value="c"> circle </option>
</select>
<br>
<br>
</br>
<input type='submit' value='calculate area'>
</form>
Page 4 of 5
</html>
results.php
<?php
if($_REQUEST['ss']=="s")
echo $_REQUEST['a']*$_REQUEST['a'];
else
echo 3.14*$_REQUEST['a']*$_REQUEST['a'];
?>
GOOD LUCK 
Page 5 of 5
Download