Part I: Theoretical/Knowledge-Based Questions
1. What is the primary difference between a static website and a dynamic website?
• Answer: A static website displays the same content to every visitor and is usually built only
with HTML/CSS. A dynamic website changes content in real-time (e.g., based on user login,
time, or database queries) and requires server-side scripting like PHP.
2. Explain the execution flow of a PHP script.
• Answer: When a user requests a .php page, the web server (Apache) identifies the PHP code,
sends it to the PHP engine for processing, interacts with a database if necessary, and finally
returns pure HTML to the user's browser.
3. Why is it important to use htmlspecialchars() or prepared statements in PHP?
• Answer: To prevent security vulnerabilities. htmlspecialchars() prevents Cross-Site Scripting
(XSS) by converting special characters to HTML entities, and prepared statements prevent
SQL Injection by separating the SQL logic from the data.
4. What are the three main components of a XAMPP stack and their roles?
• Answer: * Apache: The web server that handles HTTP requests.
o MySQL/MariaDB: The database used to store and manage data.
o PHP: The language used to write the logic and interact with the server/database.
5. Name three rules for writing valid XHTML documents.
• Answer: 1. All tags must be closed (including self-closing tags like <br />). 2. All tags and
attributes must be in lowercase. 3. Attribute values must always be enclosed in quotation
marks.
Part II: Practical/Simulation Tasks
In a COC exam, you are often given a computer and asked to perform specific tasks.
Task 1: Environment Setup
• Prompt: "Configure a local development environment to run a PHP project."
• Expectation: You must know how to start Apache and MySQL from the XAMPP Control
Panel and place your files in the htdocs folder.
Task 2: Database Connectivity
• Prompt: "Write a PHP script to connect to a database named company_db and check if the
connection is successful."
• Key Code Snippet:
$conn = mysqli_connect("localhost", "root", "", "company_db");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
echo "Connected successfully";Task 3: Form Handling
• Prompt: "Create an HTML form that collects a user's name and email, and a PHP script that
displays the submitted data using the POST method."
• Expectation: Using <form method="POST"> in HTML and accessing data via $_POST['name'] in
PHP.
Part III: Troubleshooting & Security
1. Scenario: You see a "Permission Denied" error when your PHP script tries to upload a file
to a folder. How do you fix it?
• Answer: You must check the folder permissions on the server. The web server user (e.g.,
www-data or IUSR) must have "Write" permissions for that specific directory.
2. Scenario: Your PHP code is showing a blank page instead of an error message. What
setting should you change?
• Answer: You should check the [Link] file and ensure display_errors is set to On. (Note: This is
for development only; it should be Off in production).
Part IV: Short Identification (Quick Study)
• echo vs print: Both output data, but echo is slightly faster and has no return value, while print
returns 1.
• $_GET vs $_POST: GET sends data via the URL (visible/less secure); POST sends data in the
HTTP header (invisible/more secure).
• include vs require: include produces a warning if the file is missing (script continues); require
produces a fatal error (script stops).
• [Link]: The default filename the web server looks for when a directory is accessed.