BIT301 · TU past paper
Web Technology II 2080 question paper
The complete TU 2080 exam paper for Web Technology II (BIT301), all 12 questions with solved model answers written to the mark scheme.
Tap a question to open its answer.
- 110 marksEmbedding PHP code in web pagesHideAnswer
How can you embed PHP code in web pages? Write a PHP program to illustrate the concepts of continue and break statements.[10]
PHP (Hypertext Preprocessor) is a server-side scripting language. PHP code is embedded directly within HTML documents using special delimiters (tags). The web server processes the PHP code and sends only the resulting HTML output to the ...
- 210 marksParameters by referenceHideAnswer
Describe variables and missing parameters with examples. Write a PHP program to implement functions containing parameters by reference.[10]
--- A variable in PHP is a named storage location that holds a value. PHP variables: - Start with a
- 310 marksDatabase connection creationHideAnswer
How can you create a database connection? Create a PHP form that includes text field, password field, radio button elements. Now write a function to insert the data in the fields into a database table.[10]
PHP does not talk to MySQL directly, it uses an extension. Two are current: MySQLi, which works with MySQL and MariaDB only, and PDO, which puts the same interface in front of a dozen database engines. Both open a connection from four pi...
- 45 marksString comparison and approximate equalityHideAnswer
How is the approximate equality of two strings done in PHP? Write a program to demonstrate it. [5]
In PHP, approximate equality of two strings is performed using the double equals operator (==) with type juggling, or more specifically, the concept of approximate/loose comparison. However, for string similarity/approximate matching, PH...
- 55 marksCookie creation and handlingHideAnswer
What is a cookie? Write PHP program to create cookie. [5]
A cookie is a small piece of data that a server sends to the user's web browser. The browser stores it and sends it back with subsequent requests to the same server. Cookies are commonly used to: - Remember user login information - Track...
- 65 marksError reporting and configurationHideAnswer
Define error reporting and error suppression with examples. [5]
These two settings sit on opposite sides of the same question: how much should a PHP script say when something goes wrong. Error reporting decides which classes of problem PHP announces at all, and error suppression silences the announce...
- 75 marksFile writing operationsHideAnswer
Write a PHP program to write on a file. [5]
PHP provides built-in functions to handle file operations. The most common approach uses fopen(), fwrite(), and fclose() functions. --- Function Description ----------------------- fopen(filename, mode) Opens a file; returns a file handl...
- 85 marksException handling and try catchHideAnswer
Write a PHP program to illustrate the use of exception handling. [5]
Exception handling lets a script deal with a runtime failure at the place that knows what to do about it, instead of letting the failure end the request. The code that might fail goes inside try, throw raises an object describing the fai...
- 95 marksAnonymous functions and variable functionsHideAnswer
Differentiate anonymous function from variable function. [5]
An anonymous function (also called a closure) is a function that is defined without a name. It can be assigned to a variable, passed as an argument, or returned from another function. Syntax: - The function itself has no identifier/name....
- 105 marksClass properties and attributesHideAnswer
Write a PHP program to access properties and methods of a class. [5]
Concept Syntax Description --------- Define a class class ClassName { } Blueprint for objects Create an object $obj = new ClassName(); Instance of a class Access property $obj-propertyName Using arrow operator - Access method
- 115 marksArray element insertion and removal with aHideAnswer
How can you remove and insert elements in an array? Explain by writing a PHP program using array_splice() for inserting and removing elements in an array. [5]
arraysplice() is a built-in PHP function used to remove, replace, or insert elements in an array. It modifies the original array directly. --- Parameter Description ------ $array The input array (modified in place) $offset Starting index...
- 125 marksInheritance and class hierarchyHideAnswer
Write a PHP program to demonstrate the concept of inheritance. [5]
Inheritance is an OOP concept where a child class (derived class) acquires the properties and methods of a parent class (base class) using the extends keyword in PHP. --- --- --- Concept Description ------ extends Used to inherit parent ...