Web Technology 40 Revision Questions & Answers
1. What is the difference between GET and POST methods in HTML forms?
- GET: Appends data to URL, less secure, used for retrieving data.
- POST: Sends data in body, more secure, used for submitting data.
2. Explain the concept of sessions and cookies in PHP.
- Session: Stores data on server across pages.
- Cookie: Stores data in browser, can persist longer.
3. What is AJAX and how does it improve user experience?
- AJAX allows asynchronous communication with the server without page reload.
4. What are the types of arrays in PHP with examples?
- Indexed, Associative, Multidimensional arrays with respective syntax.
5. What is the difference between include() and require() in PHP?
- include() issues warning; require() halts execution if file not found.
6. Explain XML and its significance in web development.
- XML is used to store and transport data in a structured way.
7. How do you connect PHP with a MySQL database?
- Use mysqli_connect(), mysqli_query(), mysqli_close() functions.
8. What is a constructor and destructor in PHP classes?
- Constructor runs on object creation; destructor runs on object destruction.
9. What is form validation in JavaScript?
- Ensures form fields meet certain criteria before submission.
10. What is the purpose of isset() and empty() in PHP?
- isset(): checks if set
- empty(): checks if value is empty
11. Difference between client-side and server-side scripting.
- Client-side: runs in browser (HTML, JS)
- Server-side: runs on server (PHP)
12. What is JSON and how is it used?
- JSON is a lightweight data format used for API communication.
13. What is a sticky form in PHP?
- Retains submitted values to avoid retyping after form submission.
14. PHP script to check if a number is even or odd.
- Use modulus operator (% 2 == 0) to determine.
15. What is DOM in JavaScript?
- DOM represents HTML as a tree, allowing dynamic content updates.
16. List and explain 3 PHP data types.
- String, Integer, Array with examples.
17. What is a foreign key in SQL?
- Links two tables, ensures data consistency.
18. What is explode() in PHP?
- Splits string into array by a delimiter.
19. Purpose of setTimeout() in JavaScript?
- Delays execution of a function by given milliseconds.
20. Difference between innerHTML and textContent.
- innerHTML parses HTML tags; textContent does not.
21. What are PHP superglobals?
- $_GET, $_POST, $_SESSION, $_SERVER are globally accessible variables.
22. How to create and read files in PHP?
- Use fopen(), fwrite(), fread(), fclose().
23. JavaScript function to validate email?
- Use regex pattern with test() method.
24. Difference between == and === in JavaScript?
- == checks value, === checks value + type.
25. Error handling using try-catch in PHP.
- try { ... } catch (Exception $e) { ... }
26. Foreign key constraint in SQL.
- Ensures relationship between two tables with referential integrity.
27. What are HTML5 semantic elements?
- Tags like <header>, <footer>, <section>, <article> improve meaning.
28. How is form data submitted using AJAX?
- Use XMLHttpRequest with POST and setRequestHeader().
29. Use of header() in PHP?
- Sends raw HTTP headers (e.g., redirection).
30. Differences between MySQL and PostgreSQL.
- MySQL: fast, less features
- PostgreSQL: advanced, SQL compliant.
31. What are PHP magic constants?
- __LINE__, __FILE__, __DIR__, __FUNCTION__, etc.
32. Role of mysqli_fetch_assoc()?
- Fetches result row as associative array.
33. Explain CSS box model.
- Content Padding Border Margin.
34. What is JavaScript event listener?
- Responds to events like click, input using addEventListener().
35. How to create responsive layout with CSS?
- Use media queries and flexbox/grid layout.
36. CRUD operations in SQL?
- Create, Read, Update, Delete operations on database records.
37. How does PHP handle form submissions?
- Uses $_POST or $_GET to collect form data.
38. Difference between isset() and empty() in PHP.
- isset: is set and not null; empty: evaluates to false.
39. What is JOIN in SQL? Types?
- INNER, LEFT, RIGHT, FULL joins to combine data from tables.
40. What is output buffering in PHP?
- Stores output in memory before sending to browser using ob_start().