6-Develop Server-Side Web Applications Using PHP
6-Develop Server-Side Web Applications Using PHP
061306T4CPM
COMPUTER PROGRAMMING LEVEL 6
IT/OS/CP/CR/09/6/A
DEVELOP SERVER-SIDE WEB APPLICATIONS USING PHP
NOV/DEC 2023
WRITTEN ASSESSMENT
TIME: 3 Hours
INSTRUCTIONS TO CANDIDATE:
1. The paper consists of two sections: A and B
Page 1 of 4
©2023 TVET CDACC
1. Explain the meaning of server-side application development and give TWO examples of
2. Outline the function of the following super-global functions as used in PHP programming
language.
i. $_SERVER (2 Marks)
3. Explain any TWO types of errors that a PHP programmer is likely to encounter during
4. Mmena is an experienced web designer who prefers to use PHP for server-side scripting
over other languages. List FOUR reasons for his preference. (4 Marks)
5. Outline TWO PHP functions that can be used to escape html code on form. (4 Marks)
6. Peter wants to submit a form data to the database but he is not sure which method to use
between POST and GET. Contrast the two methods and advise him accordingly.
(4 Marks)
7. Write a PHP script that can be used to generate all even numbers between 0-100. Use for
loop. (6 Marks)
9. With the aid of a syntax, explain a ternary operator in PHP language. (4 Marks)
10. Outline TWO types of arrays as used in a sever side programming language. (2 Marks)
Page 2 of 4
©2023 TVET CDACC
ii. Explain any THREE methods used to validate information from a text box
(6 Marks)
b) Arrays plays a vital role in PHP programming. Use the knowledge you have on arrays
to answer the following questions.
i. Explain TWO advantages of using arrays in PHP programming. (2 Marks)
ii. Assuming table 1 below is a representation of a database table, write a PHP code
snippet that will display the data as it appears. (8 Marks)
b) Control structures help a program to control the execution of a program. Use the
knowledge on Control structures to answer the following questions.
i. Contrast while and do while loops as used in PHP (2 Marks)
ii. Use the if…else control structure to computer net salary of an employee whose
tax is calculated using the table 2 below. (8 Marks)
Hint: net salary=salary-tax
Page 3 of 4
©2023 TVET CDACC
13.
a) In PHP programming language, the use of constants is considered to be one of the best
practices.
ii. Write a PHP script that declares PI as a constant whose value is 3.142. The script
should be used to calculate the area of a circle whose radius is 7.4. (6 Marks)
b) i. With an aid of an example, explain the for each loop in PHP. (4 Marks)
ii. Explain any THREE types of data used in PHP programming language.
(6 Marks)
14.
(6 Marks)
Page 4 of 4