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

PHP Object-Oriented PHP Basics Building the Recipe Static

Marwa Rashad
Marwa Rashad
4,198 Points

In the last objective of Static functions, I dont know what should I pass in the static method?

Should I pass the $room->getDimensions()? How would it work while the static function is expecting an array $size). I dont get it. Please help.

index.php
<?php

class Render {

   public static function displayDimensions($size) { 
   return $size[0]. " x ".  $size[1];
   }

  public static function detailsKitchen($room) {

    return "Kitchen Dimensions: ". Render::displayDimensions($room->getDimensions());
  }

}



?>

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Marwa Rashad,

When working with static types in PHP there is a special keyword called self which allows us to access the statically typed properties and methods of an class. In this case you would substitute Render:: with self::.

Happy coding!

Marwa Rashad
Marwa Rashad
4,198 Points

Hello Chris! Thanks a lot. Still I have tried this and still not working:

class Render {

  public static function displayDimensions($size) {

    return $size[0]. ' x '. $size[1];

  }

  public static function detailsKitchen ($room) {

    return "Kitchen Dimensions: ". self::displayDimensions($room->getDimensions);

  }

}

?>