2080

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.

Past Papers2082208120802079

Tap a question to open its answer.

  1. Q1.10 marksEmbedding PHP code in web pagesAnswer

    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 browser. This is the most portable and universally supported...

  2. Q2.10 marksParameters by referenceAnswer

    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

  3. Q3.10 marksDatabase connection creationAnswer

    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 pieces of information, the host, the database user, that user'...

  4. Q4.5 marksString comparison and approximate equalityAnswer

    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, PHP provides the built-in function: The most common approaches...

  5. Q5.5 marksCookie creation and handlingAnswer

    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 user sessions - Store user preferences - Maintain state bet...

  6. Q6.5 marksError reporting and configurationAnswer

    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 announcement for one expression. The first is a development and oper...

  7. Q7.5 marksFile writing operationsAnswer

    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 handle fwrite(handle, string) Writes a string to the file fclose(...

  8. Q8.5 marksException handling and try catchAnswer

    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 failure, one or more catch blocks handle it, and an optional fi...

  9. Q9.5 marksAnonymous functions and variable functionsAnswer

    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. - It is defined using the function keyword without a name. ...

  10. Q10.5 marksClass properties and attributesAnswer

    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 $obj-methodName() Using arrow operator - Access inside class $this-prop...

  11. Q11.5 marksArray element insertion and removal with aAnswer

    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 position $length Number of elements to remove $replacement ...

  12. Q12.5 marksInheritance and class hierarchyAnswer

    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 class into child class parent::construct() Calls the constru...