How unit 4 is examined
XML basics, DTD versus Schema, XSLT, then PHP: control structures, forms (GET/POST), cookies versus sessions and OOP carry the marks.
Introduction to XML
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Medium weight</span>
Definition. <mark>XML (eXtensible Markup Language) is a W3C markup language for describing, storing and transporting data, in which the author defines his own tags.</mark>
Key points.
- XML describes what the data is, while HTML describes how data is displayed.
- XML tags are user-defined and extensible; HTML tags are predefined.
- XML is case-sensitive and strict: every tag must be closed and properly nested, while HTML tolerates errors.
- An XML document has a prolog (
<?xml version="1.0"?>), exactly one root element, nested child elements and optional attributes. - XML is platform-independent plain text, so different systems can exchange it.
| Basis | HTML | XML |
|---|---|---|
| Purpose | Displays data | Describes and carries data |
| Tags | Predefined | User-defined |
| Case | Not case-sensitive | Case-sensitive |
| Closing tags | Optional for some (<br>) |
Mandatory for all |
| Errors | Browser ignores them | Parser stops (must be well-formed) |
| Root | Fixed <html> |
Any single root |
| Attribute quotes | Optional | Mandatory |
Answer frame. Open with the definition; draw the comparison table; add one XML snippet showing prolog, root and nesting; close with "XML carries data, HTML presents it".
Asked: [7 marks] (Nov 2019, Jun 2025) Differentiate HTML and XML. What is XML and how does it differ from HTML? Describe the basic structure of an XML document.
Uses of XML
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Low weight</span>
Definition. <mark>XML is used for platform-independent storage and exchange of structured data.</mark>
Key points.
- Extensibility: authors invent tags that fit their data, so one format serves books, orders or feeds.
- Readability: it is plain text that humans and programs can both read.
- Validation: a DTD or Schema checks the structure before use.
- Interoperability: different platforms and languages exchange data through it, as in RSS feeds, SOAP web services and configuration files.
- Data is separate from presentation, so XSLT can render one file in many forms.
Asked: [7 marks] (Jun 2025) Discuss the advantages of using XML for data storage and exchange in web applications.
Simple XML
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. A simple XML document is a well-formed document: prolog, one root element, nested elements.
Key points.
- Every start tag has a matching end tag, or is self-closed like
<a/>. - Elements nest properly and there is one root.
- Attribute values are quoted; names are case-sensitive.
- Comments are written
<!-- ... -->.
<?xml version="1.0"?>
<student><name>Ravi</name><roll>101</roll></student>
XML keycomponents
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">High weight</span>
Definition. <mark>An XML document is built from a prolog, elements, attributes, text, comments, entities and a root element; it is well-formed when it obeys the syntax rules.</mark>
Key points.
- Prolog: the declaration
<?xml version="1.0" encoding="UTF-8"?>states the version and encoding. - Element: a start tag, content and end tag, such as
<name>Ravi</name>; elements nest to form a tree. - Root element: exactly one element contains all others.
- Attribute: a name="value" pair inside the start tag giving extra information about the element, such as
<book id="5">; the value must be quoted and the name unique within the element. - Text (PCDATA) is the character data inside an element; CDATA sections hold text that the parser must not interpret.
- Entities: predefined references such as
< > & " 'stand for reserved characters. - Comments and processing instructions:
<!-- -->for notes. - Well-formed rules: one root, proper nesting, closed tags, quoted attributes, case-sensitive names.
- Valid: well-formed and also conforming to a DTD or Schema.
Example.
<?xml version="1.0"?>
<library>
<book id="5"><title>PHP</title></book>
</library>
Answer frame. Open with the XML definition; then list components 1-7 with the example above; state attributes with the id example; close with well-formed versus valid, and mention the HTML difference in one line.
Asked: [7 marks] (Dec 2020) What is XML? What are the attributes of XML? Asked: [14 marks] (Dec 2024) Write a short note: XML Key Components (with OOP in PHP, MySQL and Need for CSS).
DTD andSchemas
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">High weight</span>
Definition. <mark>A DTD (Document Type Definition) is a grammar that defines the legal elements, attributes and entities of an XML document, so that the document can be validated.</mark>
Key points.
- Purpose: a DTD checks the structure of an XML file; a document that obeys it is valid.
- Element declaration:
<!ELEMENT name (content)>; content can be#PCDATA,EMPTY,ANYor a child list, with+one or more,*zero or more,?optional,,sequence and|choice. - Attribute declaration:
<!ATTLIST book id CDATA #REQUIRED>; types are CDATA, ID, enumerated; defaults are#REQUIRED,#IMPLIED,#FIXED. - Entity declaration:
<!ENTITY co "RGPV">defines a reusable text; used as&co;. - Internal DTD sits inside the XML file in
<!DOCTYPE root [ ... ]>. - External DTD is a separate
.dtdfile, linked by<!DOCTYPE root SYSTEM "file.dtd">orPUBLIC "id" "url", and can be shared by many documents. - Both together: the DOCTYPE names an external file and also holds an internal subset in
[ ]; the internal declarations are read first and override the external ones. - XML Schema (XSD) is the XML-based, richer alternative to a DTD.
Example (internal plus external).
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd" [
<!ELEMENT note (to,body)>
<!ATTLIST note id CDATA #REQUIRED>
]>
<note id="1"><to>Ravi</to><body>Hi</body></note>
| Basis | DTD | XML Schema (XSD) |
|---|---|---|
| Syntax | Own non-XML syntax | Written in XML |
| Data types | Only text (PCDATA, CDATA) | Rich types: string, integer, date, boolean |
| Namespaces | Not supported | Supported |
| Extensibility | Limited, cannot extend types | Types can be extended and reused |
| Occurrence control | Only ? * + |
Exact minOccurs/maxOccurs |
| Parsing | Needs a separate parser | Same XML parser and tools |
Answer frame. DTD question: define, give purpose, components (element, attribute, entity), internal versus external, then the example; close with "the DTD validates structure". Both-DTDs question: draw the example above and explain the DOCTYPE line. Comparison: table above plus one XSD snippet, <xs:element name="age" type="xs:integer"/>.
Asked: [7 marks] (Nov 2019, Dec 2020, Dec 2024) Explain the term DTD in detail. What is DTD? Why do we use it? What are its applications? Asked: [7 marks] (Jun 2020) Explain the different components of DTD with example. Asked: [7 marks] (Nov 2023) Compare the critical differences between DTD and XML Schema. Asked: [7 marks] (Dec 2024) How can both Internal and External DTDs be used in an XML file? Show with an example. Asked: [7 marks] (Dec 2025) Explain XML components, DTD and XML schemas.
Using XML with applications
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. An XML parser reads an XML file and gives an application access to its data.
Key points.
- DOM parser loads the whole file as a tree in memory, allowing random access and change.
- SAX parser is event-based and streams the file, using little memory but only forward reading.
- PHP reads XML with
simplexml_load_file("a.xml")or the DOM classes. - Applications use XML for config files, feeds and web services.
Transforming XML using XSL and XSLT
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Medium weight</span>
Definition. <mark>XSL is the stylesheet language for XML, and XSLT (XSL Transformations) converts an XML document into another format such as HTML, using template rules.</mark>
Key points.
- XSLT is itself written in XML, and the stylesheet root is
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">. <xsl:template match="/">defines a rule applied to the node matched by an XPath expression;/is the root.<xsl:value-of select="name"/>writes the value of a node.<xsl:for-each select="students/student">loops over repeated nodes.<xsl:if>and<xsl:choose>give conditions, and<xsl:sort>orders output.- The XML file links the stylesheet with
<?xml-stylesheet type="text/xsl" href="s.xsl"?>, and the processor produces the output tree. - Its use is to present the same XML data as HTML for browsers.
Example. s.xml: <students><student><name>Ravi</name></student></students>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html><body>
<xsl:for-each select="students/student">
<p><xsl:value-of select="name"/></p>
</xsl:for-each>
</body></html>
</xsl:template>
</xsl:stylesheet>
Output: <html><body><p>Ravi</p></body></html>
Answer frame. Open by defining XSL and XSLT; show the XML, the stylesheet and the output; explain the template, value-of and for-each lines; close with "XSLT separates data from presentation".
Asked: [7 marks] (Nov 2023, Dec 2025) Briefly explain XSL transformation with an example of script. Explain transformation of XML using XSL/XSLT.
PHP introduction and basic syntax
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Low weight</span>
Definition. <mark>PHP (Hypertext Preprocessor) is an open-source, server-side scripting language embedded in HTML.</mark>
Key points.
- PHP code sits between
<?phpand?>and every statement ends with a semicolon; files use.php. - Variables start with
$, need no type declaration and are case-sensitive; comments use//,#and/* */. echoandprintoutput text; operators are arithmetic, comparison, logical, assignment and string (.).- Types are integer, float, string, boolean, array, object and NULL.
- The server runs the script and sends only the HTML result to the browser.
<?php $n = "RGPV"; echo "Hello " . $n; // Hello RGPV ?>
Asked: [7 marks] (Dec 2025) Explain PHP syntax, arrays, functions and form processing.
Decision and looping
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Low weight</span>
Definition. Control structures decide which statements run (decision) or repeat them (loops).
Key points.
- Decision:
if,if...else,elseifandswitchwithcase,break,default. - Loops:
for(known count),while(test first),do...while(runs at least once) andforeach(arrays). breakleaves a loop andcontinueskips one iteration.- Example below shows if and for.
<?php
$m = 55;
if ($m >= 40) { echo "Pass"; } else { echo "Fail"; } // Pass
for ($i = 1; $i <= 3; $i++) { echo $i; } // 123
foreach (["a", "b"] as $v) { echo $v; } // ab
?>
Asked: [7 marks] (Nov 2022) Explain about the control structures in PHP with illustrations.
PHP and HTML
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. PHP is embedded in HTML so the page mixes static markup with generated content.
Key points.
- Switch between them with
<?php ... ?>, and<?= $x ?>is a shortcut for echo. - Output from
echomay contain HTML tags. - The server executes the PHP first; the browser never sees the PHP code.
- Loops can wrap HTML to build tables.
Arrays
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. An array stores many values under one variable name.
Key points.
- Indexed:
$a = array(10, 20);accessed by number,$a[0]. - Associative:
$p = ["name" => "Ravi"];accessed by key. - Multidimensional: an array of arrays,
$m[1][0]. - Useful functions:
count(),sort(),array_push(),in_array().
Functions
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. A function is a named, reusable block of code.
Key points.
- User-defined:
function add($a, $b) { return $a + $b; }called asadd(2, 3). - Built-in functions include
strlen(),count()anddate(). - Arguments may have defaults,
function f($x = 5), and can be passed by reference with&. - Variables inside a function are local unless declared
global.
Browser control and detection
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. PHP detects the visitor's browser from the HTTP header and can control it by sending headers.
Key points.
$_SERVER['HTTP_USER_AGENT']holds the browser and OS name.get_browser()decodes it into details.header("Location: page.php");redirects the browser and must run before any output.- Detection lets the page serve content suited to the browser.
String
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. A string is a sequence of characters in single or double quotes.
Key points.
- Double quotes expand variables, single quotes do not;
.joins strings. - Common functions:
strlen(),strrev(),strtoupper(),strpos(),substr(),str_replace(). explode()splits a string into an array andimplode()joins an array.trim()removes surrounding spaces.
Form processing
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Medium weight</span>
Definition. <mark>Form processing is collecting user input from an HTML form and handling it in a PHP script through the $_GET or $_POST superglobals.</mark>
Key points.
- The form's
methodattribute chooses GET or POST andactionnames the script. - GET appends data to the URL as
?name=Ravi, so it is visible, bookmarkable and limited in length (about 2000 characters). - POST sends data in the request body, so it is hidden and has no practical size limit.
- Use GET for searches and POST for passwords and uploads.
isset()andempty()test for missing input, andfilter_var($e, FILTER_VALIDATE_EMAIL)checks the email format.
| Basis | GET | POST |
|---|---|---|
| Data location | URL query string | Request body |
| Visibility | Visible | Hidden |
| Length | Limited | Practically unlimited |
| Security | Weak | Better |
| Bookmark/cache | Yes | No |
| PHP array | $_GET |
$_POST |
Example (validation script).
<form method="post">
User <input name="u"> Pass <input name="p" type="password"> Email <input name="e"><input type="submit">
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["u"]) || empty($_POST["p"]) || empty($_POST["e"])) echo "Fill all fields";
elseif (!filter_var($_POST["e"], FILTER_VALIDATE_EMAIL)) echo "Invalid email";
else echo "Welcome " . htmlspecialchars($_POST["u"]);
}
?>
Answer frame. GET/POST question: define form handling, table above, one short form with $_GET and $_POST; close with when to use each. Script question: draw the form, then the empty check, then the email check, then the success message.
Pitfall: Sending a password with GET exposes it in the URL and browser history.
Asked: [7 marks] (Jun 2020) Write a PHP script which takes the user name, password and email values and checks whether the textboxes are filled and whether the email format is correct. Asked: [7 marks] (Nov 2022, Nov 2023) State the differences between GET and POST methods. Explain form handling with the get and post methods in PHP.
Files
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>
Definition. PHP reads, writes and uploads files on the server.
Key points.
fopen("a.txt", "r")opens a file; modes arer,w,a; close withfclose().fread(),fgets()read andfwrite()writes;file_exists()andunlink()check and delete.- Uploads use a form with
enctype="multipart/form-data", read from$_FILESand saved withmove_uploaded_file().
Advance features: cookies and sessions
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">High weight</span>
Definition. <mark>A cookie is a small text file stored in the client's browser, and a session stores user data on the server, identified by a session ID; both let stateless HTTP remember a user.</mark>
Key points.
- Set a cookie with
setcookie(name, value, expire, path)before any output, for examplesetcookie("user", "Ravi", time()+3600);. - Read it through
$_COOKIE["user"]; delete it by setting the expiry in the past. - A cookie lives until its expiry time, so it can persist after the browser closes.
session_start()begins a session and must be the first call on each page; data goes in$_SESSION["user"] = "Ravi";.- The server keeps the data and sends only a session ID (PHPSESSID cookie) to the browser.
session_destroy()ends the session andunset($_SESSION["user"])removes one value.- Session lifecycle: start, store, read on later pages, destroy at logout or timeout.
- Cookies suit preferences and "remember me", sessions suit login and shopping carts.
| Basis | Cookie | Session |
|---|---|---|
| Storage | Client browser | Server |
| Security | Less, user can edit it | More, only the ID is at the client |
| Lifetime | Until expiry date | Until browser closes or logout |
| Capacity | About 4 KB each | Large, server limited |
| Function | setcookie() |
session_start() |
| Array | $_COOKIE |
$_SESSION |
Example.
<?php
setcookie("user", "Ravi", time() + 3600);
session_start();
$_SESSION["role"] = "admin";
echo $_COOKIE["user"] ?? "new", $_SESSION["role"];
?>
Answer frame. Comparison: open with both definitions, table above, close with an example. Program question: define each, list the functions, then the program above with a second page reading $_SESSION.
Pitfall:
setcookie()andsession_start()after any HTML output cause a "headers already sent" error.
Asked: [7 marks] (Jun 2020, Nov 2023) Differentiate between Session and Cookie. What is the difference between sessions and cookies in PHP? Asked: [7 marks] (Nov 2022) Write about cookies and sessions in PHP with suitable program. Asked: [7 marks] (Dec 2025) Explain cookies, sessions and OOP concepts in PHP. Asked: [14 marks] (Dec 2024) Explain: i) Cookies and sessions ii) Creating Database iii) Planning and Publishing Websites (the last two belong to Units 5 and 1).
Object oriented programming with PHP
<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Medium weight</span>
Definition. <mark>Object oriented programming organises code into classes and objects that combine data (properties) and behaviour (methods).</mark>
Key points.
- Class is the blueprint declared with
class; an object is an instance made withnew. - Properties and methods are reached with
->, and$thisrefers to the current object. - The constructor
__construct()runs automatically when an object is created. - Encapsulation hides data using
public,protectedandprivatevisibility. - Inheritance: a child class takes the parent's properties and methods using
extends, and adds its own. - Polymorphism: a child overrides a parent method, so the same call behaves differently; interfaces (
implements) also give this. - Advantages: reuse, easy maintenance and modular web applications.
<figure class="ds-fig" style="margin:1.4rem 0;overflow-x:auto"><svg xmlns="http://www.w3.org/2000/svg" id="dsfig-u4-01" viewBox="0 0 283 134" width="283" height="134" role="img" aria-label="Inheritance: parent class Animal, child classes Dog and Cat"><style>#dsfig-u4-01 .e{stroke:#454C5A;stroke-width:1.4;fill:none}#dsfig-u4-01 .e.hi{stroke:#2340B8;stroke-width:2.6}#dsfig-u4-01 .n{fill:#FFFFFF;stroke:#16181D;stroke-width:1.4}#dsfig-u4-01 .n.hi{fill:#E3E9FC;stroke:#2340B8;stroke-width:2.2}#dsfig-u4-01 .n.rb-b{fill:#16181D;stroke:#16181D}#dsfig-u4-01 .n.rb-r{fill:#BD3227;stroke:#BD3227}#dsfig-u4-01 text{font-family:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;font-size:13px}#dsfig-u4-01 .t{fill:#16181D;font-weight:500}#dsfig-u4-01 .t.inv{fill:#FFFFFF;font-weight:700}#dsfig-u4-01 .kd{stroke:#16181D;stroke-width:1.2}#dsfig-u4-01 .dot{fill:#16181D}#dsfig-u4-01 .ann{fill:#2340B8;font-size:11px;font-weight:700}#dsfig-u4-01 .lbl{fill:#6F7787;font-family:system-ui,-apple-system,sans-serif;font-size:12px;font-weight:700}#dsfig-u4-01 .ptr{fill:#2340B8;font-size:12px;font-weight:700}#dsfig-u4-01 .ah{fill:#454C5A}#dsfig-u4-01 .ah.hi{fill:#2340B8}#dsfig-u4-01 .wl rect{fill:#FFFFFF;stroke:#DCE0E7}#dsfig-u4-01 .wl .t{font-size:12px;font-weight:700}#dsfig-u4-01 .wl.hi rect{fill:#2340B8;stroke:#2340B8}#dsfig-u4-01 .wl.hi .t{fill:#FFFFFF}html.dark #dsfig-u4-01 .e{stroke:#B1B7C3}html.dark #dsfig-u4-01 .e.hi{stroke:#8FA3FF}html.dark #dsfig-u4-01 .n{fill:#161920;stroke:#E6E8ED}html.dark #dsfig-u4-01 .n.hi{fill:#1E2748;stroke:#8FA3FF}html.dark #dsfig-u4-01 .n.rb-b{fill:#E6E8ED;stroke:#E6E8ED}html.dark #dsfig-u4-01 .n.rb-r{fill:#FF7E71;stroke:#FF7E71}html.dark #dsfig-u4-01 .t{fill:#E6E8ED}html.dark #dsfig-u4-01 .t.inv{fill:#0F1115}html.dark #dsfig-u4-01 .kd{stroke:#E6E8ED}html.dark #dsfig-u4-01 .dot{fill:#E6E8ED}html.dark #dsfig-u4-01 .ann{fill:#8FA3FF}html.dark #dsfig-u4-01 .lbl{fill:#858D9C}html.dark #dsfig-u4-01 .ptr{fill:#8FA3FF}html.dark #dsfig-u4-01 .ah{fill:#B1B7C3}html.dark #dsfig-u4-01 .ah.hi{fill:#8FA3FF}html.dark #dsfig-u4-01 .wl rect{fill:#161920;stroke:#2A2E37}html.dark #dsfig-u4-01 .wl.hi rect{fill:#8FA3FF;stroke:#8FA3FF}html.dark #dsfig-u4-01 .wl.hi .t{fill:#0F1115}</style><defs><marker id="ah7" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah" d="M0,1 L9,5 L0,9 z"/></marker><marker id="ahh7" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah hi" d="M0,1 L9,5 L0,9 z"/></marker></defs><line class="e" x1="129.5" y1="39" x2="52.5" y2="103"/><line class="e" x1="129.5" y1="39" x2="206.5" y2="103"/><rect class="n" x="96" y="24" width="67" height="30" rx="8"/><text class="t" x="129.5" y="39" dy=".35em" text-anchor="middle">Animal</text><circle class="n" cx="52.5" cy="103" r="17"/><text class="t" x="52.5" y="103" dy=".35em" text-anchor="middle">Dog</text><circle class="n" cx="206.5" cy="103" r="17"/><text class="t" x="206.5" y="103" dy=".35em" text-anchor="middle">Cat</text></svg><figcaption style="font-size:.82em;opacity:.72;margin-top:.45rem">Inheritance: parent class Animal, child classes Dog and Cat</figcaption></figure>
Example.
<?php
class Animal { function speak() { return "..."; } }
class Dog extends Animal { function speak() { return "Bark"; } }
$d = new Dog();
echo $d->speak(); // Bark
?>
Answer frame. OOP question: define class, object, then points 4-6 with the example; close with advantages. Inheritance question: define inheritance, draw the tree, show extends, state types (single, multilevel, hierarchical), close with reuse.
Asked: [7 marks] (Jun 2020, Jun 2025) Explain the concept of object oriented programming with PHP, including encapsulation, inheritance and polymorphism. Asked: [7 marks] (Nov 2019) Explain about inheritance with suitable diagram.
Last-minute revision
- XML is case-sensitive, has one root, and every tag must close.
- HTML displays data; XML describes data; XML tags are user-defined.
- DTD:
<!ELEMENT>,<!ATTLIST>,<!ENTITY>; internal uses[ ], external usesSYSTEM "x.dtd". - XSD is written in XML and has data types and namespaces; DTD has neither.
- XSLT elements: template, value-of, for-each, if, choose, sort.
- PHP tags are
<?php ... ?>, variables start with$, statements end with;. - GET is in the URL and limited; POST is in the body and safer.
- Cookie on client with
setcookie(), session on server withsession_start(). - Cookie is about 4 KB; call both before any output.
- OOP:
class,new,extends,__construct, visibility public/protected/private.
Memory hooks
- DTD grammar: E-A-E, Element, Attlist, Entity.
- GET = Glass window (visible), POST = Post box (hidden).
- Cookie crumbs stay with the client; the session ticket is held by the server.
- Inheritance: child
extendsparent.
Coverage checklist
- Introduction to XML: HTML vs XML (Nov 2019, Jun 2025).
- uses of XML: advantages of XML (Jun 2025).
- simple XML: well-formed structure.
- XML keycomponents: what is XML, attributes (Dec 2020); short note (Dec 2024).
- DTD andSchemas: DTD, components, DTD vs Schema, internal and external, XML components (Nov 2019 to Dec 2025).
- Using XML with application: DOM and SAX parsers.
- Transforming XML using XSL and XSLT: XSLT example (Nov 2023, Dec 2025).
- PHP: Introduction and basic syntax of PHP: PHP syntax (Dec 2025).
- decision and looping with examples: control structures (Nov 2022).
- PHP and HTML: embedding.
- Arrays: indexed, associative, multidimensional.
- Functions: user-defined and built-in.
- Browser control and detection: user agent, header.
- string: string functions.
- Form processing: GET vs POST, validation script (Jun 2020, Nov 2022, Nov 2023).
- Files: fopen, uploads.
- Advance Features: Cookies and Sessions: comparison, program, short note (Jun 2020 to Dec 2025).
- Object Oriented Programming with PHP: OOP, inheritance (Nov 2019, Jun 2020, Jun 2025).