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 trialBoban Rajovic
360 PointsI don't understand the task 4/4 it is really confusing , please help.
I'm just really confused what im getting from $room and in which way to dispaly it , can someone please explain ..
<?php
class Render {
public static function displayDimensions($size){
return $size[0] . " x " . $size[1];
}
public static function detailsKitchen ($room){
}
}
?>
1 Answer
Spenser Hale
20,915 PointsHello Boban Rajovic,
I answered another on of your questions. It appears you are having a hard time understanding how to use objects. Please review earlier videos linked with notes below to have a better understanding.
Properties
To read and set from a property of a object use the -> syntax with name, example:
<?php
$object = new stdClass();
$object->count = 0;
$object->count += 1;
$count = $object->count;
// $count would be 1.
Methods
To read from a method of a an object it is same as a property, but with () at the end, example:
<?php
$dimensions = $room->getDimensions();
// $dimensions would be array with two values in array, x and y values, ie [12,14]
$x = $dimensions[0];
// $x would be 12
$y = $dimensions[1];
// $y would be 14
Putting it all together:
<?php
class Render {
public static function displayDimensions($size){
return $size[0] . " x " . $size[1];
}
public static function detailsKitchen ($room){
$size = $room->getDimensions();
$displayDimensions = static::displayDimensions($size);
return 'Kitchen Dimensions: ' . $displayDimensions;
}
}