Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Luis Alveiro Martinez Botello](https://secure.gravatar.com/avatar/9d9ac141a5a5ef982910ae54cfb43ddb?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Luis Alveiro Martinez Botello
2,726 PointsMy code is not been showed
<?php class Product { //properties public $name = 'default_name'; public $price = 0; public $desc = 'default description';
function __construct($name, $price, $desc){
$this->name = $name;
$this->price = $price;
$this->desc = $desc;
}
//methods
public function getInfo(){
return "Product Name: ". $this->name;//return some info about our Product.
}
} $p = new Product(); $shirt = new Product("Space Juice T-Shirt", 20, "Awesome Grey T-Shirt"); $soda = new Product("Space Juice Soda", 2, "Grape Flavored Thirst Mutilator");
echo $shirt->getInfo();
?>
1 Answer
![foss](https://secure.gravatar.com/avatar/79da4de516379655e9b98f530260c0ad?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
foss
7,601 PointsYou are creating the $p, but have not provided the required variables for the constructor function.
One option is to comment out the line: $p = new Product();
Another option is to pass along the variables when you create it: $p = new Product("your product name", "your product price", "your product description");