Вы находитесь на странице: 1из 4

Exercises (DFP3143)- Set 2

QUESTION 1
a) List TWO (2) features in PHP
b) Identify TWO (2) web server softwares.
c) Describe an anchor tag in HTML?
d) Write a HTML tag for unordered list by referring the output in Figure B1.

Figure B1
e) Answer the following questions.
i. List TWO (2) rules for naming the variable in PHP.
ii. State TWO (2) attributes of forms.
iii. State TWO (2) differences between GET and POST method.

QUESTION 2
a) Question i, ii, and iii are based on Figure B2.

<?php

$cars=array('Honda'=>'CRV','Toyota'=>'Vios',
'Proton'=>'Preve');
?>
<?php

$colours = array(grey,blue,black,white);

?>

Figure B2

i. Identify the value of second and third elements in cars array.


ii. State the array types of cars and colours.
iii. Write the output for the following codes:
echo $cars[Honda];
echo "</br>";
echo $colours[2];

1
Exercises (DFP3143)- Set 2

b) Question i, ii, and iii are based on the statement below.


Write a PHP program using string function to produce the following output by using
$text = Web Programming1 :
i. Output : Position for Pro is 4
ii. Output : Text length is 16
iii. Output : Sub string of the text is Program

c) Describe the PHP segment code in Figure B3.

fopen("read.txt", "x+");
Figure B3

d) MySQL is the most popular database system used with PHP to manipulate data in the
databases. State the TWO (2) MySQL features.
e) Based on Table B1, write SQL syntax to update Alis salary to 3100.00 in table
STAFF.
Table B1: STAFF
Staff_ID Staff_Name Salary Address
1 Alex 4000.00 Johor
2 Ahmad 3000.30 Johor
3 Raju 2000.20 Perak
4 Ali Kedah

f) Based on Table B2, write a command to display all male students record in
STUDENT table by using mysql_query function.
Table B2 : STUDENT
Stu_ID Stu_Name Stu_Gender
01DIP15F2015 Zara Aisyah female
01DIP15F2020 Iskandar Zulkarnain male
01DIP15F2022 Stephanie female
01DIP15F2011 Nitya A/P Ramu female

2
Exercises (DFP3143)- Set 2

QUESTION 3
a) List THREE (3) vital components that are needed to be installed in the computer system to
create PHP environment page.
b) Web page, Browser, Hyperlink, Domain, URL, HTTP and IP Address are terminologies of
web server. Explain THREE (3) web terminologies that you have learned.
c) Write HTML syntax to allow user to choose one of the Gender by using radio button and key
in input data into text field component as shown in Figure B4.

Figure B4

d) Answer each of the following questions.


i. Explain the differences between cookies and session
ii. Give an example to declare cookies and session.
e) Based on the Figure B5, answer each of the following questions.

<?php
$x = array(PHP, PERL, JAVA)

for ($i =0; $<count($x); $i++)


echo $x[$i]<br>";
}
?>
Figure B5

(i) Give output for segment code as shown in Figure B5.


(ii) Convert the PHP kod from for loop to foreach.

3
Exercises (DFP3143)- Set 2

QUESTION 4
a) Question i and ii are based on Figure B6.

PHP allows programmer to create user defined function which is used


to associate repeated code with one function call.
PHP membenarkan pengaturcara untuk mencipta fungsi takrifan
pengguna yang digunakan untuk megulangi aturcara dengan satu
panggilan fungsi.

Figure B6
i. Write a function to calculate total payment based on tax rate, quantity of item and price
input by user.
ii. Write a function to calculate total payment based on the quantity of item and the price
input by user. The tax rate is set to 5%.
b) Describe each of the file handling modes below:
i. r
ii. r+
iii. w
c) Write SQL command to create Students table to store students matric numbers,
name and addresses to the record. Set the suitable primary key.
d) Consider that the MySQL username is root and password is 1234, write a PHP code to
connect PHP files with myclass database.

Вам также может понравиться