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 trialJorge Gonzalez
3,574 PointsAnother code error.
I get nothing but a blank screen with this code:
<?php
class Product
{
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;
}
public function getInfo(){
return "Product Name: " . $this->name;
}
}
class Soda extends Product
{
public $flavor;
function __construct($name, $price, $desc, $flavor){
parent::__construct($name, $price, $desc);
$this->flavor = $flavor;
}
public function getInfo(){
return "Product Name: " . $this->name . "Flavor: ". $this->flavor;
}
$shirt = new Product("Juice T", 20, "Grey T");
$soda = new Soda("Soda", 2, "Thirst Mutilator", "Grape");
echo $soda->getInfo();
?>
1 Answer
Ted Sumner
Courses Plus Student 17,967 PointsYou do not close your Soda class. Formatting with tabs will help find these issues in the future.
Ted Sumner
Courses Plus Student 17,967 PointsTed Sumner
Courses Plus Student 17,967 Pointsedited to format code.