St. Name:

advertisement
St. Name: ……………………………….
St. #: ………………………………….
Philadelphia University
Lecturer(s): Dr. Murad Magableh , Ms. Reem Qaqa
Faculty of IT Department of MIS
Internal examiner: Dr. Ali Alawneh
Examination Paper
---------------------------------------------------------------------------------------
(731213) Introduction to Web Programming
29/03/2015 Time: 50 min
1st Exam. 2nd Sem. 2014/2015
Information for Candidates
This examination paper contains 5 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: Answer each of the following short questions:
[8 marks]
1) To execute the code written in the file c:\xampp\htdocs\test.php, what we write
in the browser address bar?
2) How to write the following HTML code inside the PHP area: <font size=10>?
3) How to write the following PHP code inside the HTML area: (echo "HI";) ?
4) Define a constant with any name and value.
5) $x = 5; Change the data type of $x to double using a function.
6) $y = 1.2; Change the data type of $y to integers using casting.
7) $z="HI"; Show the data type of $z using a function.
8) What is the value of $s?
$s="3a2b1c"; $sum=$s+5; echo $sum;
Page 1 of 6
1) localhost/test.php
2)
<?php
echo “<font size=20>”;
?>
3)
<html>
<?php
echo “hi”;
?>
</html>
4) define(“SUM”,20);
5) settype($x,”double”);
6) $y= (int)$y;
7) echo gettype($z);
8) 3a2b1c
Page 2 of 6
II. Familiar problem solving
Objectives: the aim of the following question is to evaluate your capabilities in solving familiar
cases.
Q2: What is the output of the following?
A) <?php
$a= 2.6;
$b= 9;
$c= 8;
echo ceil($a)."</br>”;
echo max($c, floor(3.3), 7, 4*2, min(9, 10, 11), rand(-$b,$b));
?>
[2 marks]
3
9
Q3: Given the following 2 PHP pages, what is the output after calling b.php page?
Page 1: a.php
<?php
Echo "WELCOME<BR>";
define("J", "2");
define("j", "3");
?>
Page 2: b.php
<?php
include("a.php");
$J = 4;
$j = 7;
echo $j + j;
echo "<BR>";
echo j + J;
echo "<BR>";
echo $J - $j ;
echo "<BR>";
echo $j - 4;
//echo ++J;
$j=$J+2;
echo "<BR>";
echo $j + j + $J + J;
?>
[3 marks]
WELCOME
10
5
-3
3
15
Page 3 of 6
III. Unfamiliar problem solving
Objectives: the aim of the following question is to evaluate your capabilities in solving unfamiliar
cases.
Q4: Find the errors in the below code and correct them:
[2 marks]
<html>
<body>
Pizza Type:<BR>
<form method="POST">
margarita <input type="radio" name="r1" value="margarita"></BR>
Vegan <input type="radio" name="r2" value="vegan"></BR>
Customer's Address:<BR>
< input type="textarea" cols="20" rows="10"></textarea>
</br>
<input type="button" value= "order pizza">
</body>
</form>
</html>
<?php
echo "you ordered ".$_GET['r1'];
?>
<html>
<body>
Pizza Type:<BR>
<form method='POST'>
margarita <input type=radio name=r1 value=margarita></BR> //0.5
Vegan <input type=radio name=r1 value=vegan></BR>
Pizza Size:
</br>
Customer's Address:<BR>
<textarea cols='20' rows='10'></textarea>//0.5
</br>
<input type='submit' value= "order pizza">//0.5
</form>
</body>//or /0.5
</html>
<?php
echo "you ordered".$_POST['r1'];//0.5
?>
Page 4 of 6
III. Unfamiliar problem solving
Objectives: the aim of the following question is to evaluate your capabilities in solving unfamiliar
cases.
Q5: 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:
[3 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
[2 marks]
Solution:
Area.html
<html>
<form action=’results.php’>//.5mark
<input type=text name='a'>//.5 mark
<br>
<select name='ss'>//.5 mark
<option value="s"> square </option>//.5 mark
<option value="c"> circle </option>
</select>mark
<br>
<br>
</br>
<input type='submit' value='calculate area'>//1 mark
</form>
</html>
Page 5 of 6
results.php
<?php
if($_REQUEST['ss']=="s")//1 mark
echo $_REQUEST['a']*$_REQUEST['a'];.5//mark
else
echo 3.14*$_REQUEST['a']*$_REQUEST['a'];//.5 mark
?>
GOOD LUCK 
Page 6 of 6
Download