Professional Documents
Culture Documents
Problem 2
Problem 2
As part of
the project, you need to implement a Product class that represents a product in the
system. The Product class should have the following properties:
In addition to the properties, the Product class should also have the following
methods:
1. __construct: a constructor method that takes the id, name, and price as
parameters and initializes the corresponding properties of the object.
3. showDetails: a method that prints the details of the product (id, name, and
formatted price) to the console.
Your task is to write the implementation of the Product class in PHP. Use the
provided template code below and fill in the missing parts:
php
class Product {
// TODO: Add properties
Expected Output:
Product Details:
- ID: 1
- Name: T-shirt
- Price: $19.99