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 trialKeegan Kemp
1,986 PointsHaving trouble with this challenge task.
I am working on a challenge task in PHP Basics 2. Im not sure how to get the desired output.
<?php
class Render {
public static function displayDimensions($size)
{
return implode(" x ", $size);
}
public static function detailsRoom($room)
{
function getName($name)
{
return $name;
}
function getDimensions($size)
{
return self::displayDimensions();
}
$room = $name . "Dimensions: " . $size;
}
echo detailsRoom();
}
?>
1 Answer
Steven Parker
231,186 PointsLooks like you got a little off track. The instructions weren't asking you to write getName or getDimensions methods, they were just letting you know that they exist in the $room object in case you wanted to use them to create the return string.
And don't forget that the instructions say to return that string instead of assigning it back to the argument or echoing it.
Keegan Kemp
1,986 PointsKeegan Kemp
1,986 PointsThank you for answering. I tried a different approach, but it says getDimensions in not defined?
Steven Parker
231,186 PointsSteven Parker
231,186 PointsThe syntax for calling it should be like what you used for getName.
So instead of
getDimensions($room)
, it would be$room->getDimensions()
.Fix that, plus one minor spacing issue, and you'll have it.
Keegan Kemp
1,986 PointsKeegan Kemp
1,986 PointsI got it! Thank you very much for your help!