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 trialWouter Vermeersch
6,913 PointsTotally stuck
Hope you guys can see my code....
I tried different things but didn't came up with a solution... This task description seems a little vague in my opinion, maybe it's just because I speak dutch ...
<?php
class Render {
static function displayDimensions($size)
{
return $size[0] ." x ". $size[1];
}
static function detailsKitchen($room)
{
return "Kitchen Dimensions: " .$self::displayDimensions($room->getDimensions());
}
static function getDimensions()
{
return array(12,14);
}
$newRoom = new Render
$newroom->detailsKitchen($newroom);
}
?>
1 Answer
Robert Leonardi
17,151 PointsHI Wouter,
You should fix your code
- to display output , you should use "print_r" or "echo"
- closed bracket of class Render was misplaced
- you forgot ";" on new Render
- you don't need input for detailsKitchen, just call the function
- you can call function within the class by just using "$this->name_of_function"
- change all "static" to "public"
try this
class Render {
public function displayDimensions($size)
{
return $size[0] ." x ". $size[1];
}
public function detailsKitchen()
{
return "Kitchen Dimensions: " .$this->displayDimensions($this->getDimensions());
}
public function getDimensions()
{
return array(12,14);
}
}
$newRoom = new Render;
print_r($newRoom->detailsKitchen()); // display output
?>
Oups... I didn't realize this is a code challenge.... You should use "self::" instead of "$self::"
it becomes
class Render {
static function displayDimensions($size)
{
return $size[0] ." x ". $size[1];
}
static function detailsKitchen()
{
return "Kitchen Dimensions: " .self::displayDimensions(self::getDimensions());
}
static function getDimensions()
{
return array(12,14);
}
}
$newRoom = new Render;
print_r($newRoom->detailsKitchen());
?>
Hope it helps