0% found this document useful (0 votes)
4 views

practicequestions

The document outlines two scenarios for PHP programming tasks: developing an order management system with OOP principles and creating a user login system for a blogging website. It specifies requirements for class structures, session management, and cookie handling, along with tasks for implementation and explanations of concepts like inheritance and the roles of cookies and sessions. Additionally, it includes practical questions related to PHP forms and login systems, focusing on data validation and user experience.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

practicequestions

The document outlines two scenarios for PHP programming tasks: developing an order management system with OOP principles and creating a user login system for a blogging website. It specifies requirements for class structures, session management, and cookie handling, along with tasks for implementation and explanations of concepts like inheritance and the roles of cookies and sessions. Additionally, it includes practical questions related to PHP forms and login systems, focusing on data validation and user experience.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

🧩 Scenario-Based Question: (Unit5)

You are hired by a small e-commerce startup to develop a simple order


management system in PHP using Object-Oriented Programming (OOP)
principles.
Requirements:
 You need to define a base class Product with properties like name, price,
and category.
 Create a constructor to initialize the values.
 Include a method getProductDetails() that returns formatted product
information.
 Create a subclass ElectronicProduct that inherits from Product and includes
an additional property warrantyPeriod.
 Override the getProductDetails() method to include warranty information.
 Use an interface Discountable with a method applyDiscount($percent) and
implement it in both classes.
Task:
1. Write PHP code to implement the above scenario using classes,
inheritance, constructors, method overriding, and interfaces.
2. Instantiate objects of both Product and ElectronicProduct classes.
3. Demonstrate usage of the applyDiscount() method.
4. Explain how inheritance and interfaces helped you organize the code
better.

🔐 Scenario-Based Question (Unit 4):


You are developing a user login system for a blogging website. The system
needs to remember users across pages and manage personalized greetings.
Requirements:
 When a user logs in, their username should be stored in a session.
 The site should also set a cookie to remember the user's preferred theme
(e.g., dark or light mode) for 7 days.
 On each page load, the site should:
o Check for an active session and greet the user with their username.

o Display the current theme based on the cookie value. If not set,
default to light mode.
 Include a "Logout" option that:
o Ends the session.

o Clears the cookie.

Tasks:
1. Write PHP scripts to:
o Handle login using $_POST, create a session, and set the cookie.

o Display a dashboard that shows the session username and theme


from cookie.
o Implement logout functionality.

2. Use appropriate string handling functions to sanitize user input.


3. Explain the role of cookies vs sessions in this scenario.
4. What would happen if cookies were disabled in the user's browser? How
would you handle it?

✅ Unit 3 Practical Question: PHP Forms

Q: Create a PHP web form that collects the user's name, email, and age. Implement the
following features:

 Use the POST method to submit data.


 Validate that:
o The name is not empty.
o The email is in a valid format.
o The age is a number and between 18 and 60.
 Display appropriate error messages if the form is invalid.
 On successful validation, display the submitted data.

✅ Unit 4 Practical Question: Cookies, Sessions, and String Handling

Q: Design a login system using PHP that includes the following:

 A login form that accepts a username and password.


 On successful login, start a session and store the username in a session variable.
 Display a welcome message using the session data on a new page.
 Set a cookie to remember the user for 1 day.
 Include a logout button that clears both the session and cookie.

You might also like