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

Okafor Matthew
PLUS
Okafor Matthew
Courses Plus Student 2,633 Points

Please Help Don't know where i got it wrong

Please am trying to solve challenge number two but i keep getting error message and here is my code which i compare with some other answers from people but the error message keep puping up. here is my code <?php

class Render { public $aize = array("length"=>"", "width"=>""); public static function displayDimensions($size){

return $size[0]. " * ". $size[1];

}

}

index.php
<?php

class Render {
 public $aize = array("length"=>"", "width"=>"");
  public static function displayDimensions($size){

   return $size[0]. " * ". $size[1];

   }

}

?>

2 Answers

Pierre Lindgren
Pierre Lindgren
1,905 Points

Hello,

You have misspelled $aize, it should be $size.

Kind regards

Algirdas Lalys
Algirdas Lalys
9,389 Points

Hello Okafor Matthew,

Well actually you are going the right way you just don't need that $size property. Let's go step by step in these 2 Tasks. First task asks us Create a public static method named displayDimensions that accepts a single parameter named $size. which is pretty straightforward.

<?php
class Render {
    // Task 1 create public static displayDimensions function that accepts $size parameter
    public static function displayDimensions($size) {

    }
}
?>

Task 2 asks us Add a return value to the displayDimensions method that returns these values as a string "length x width". Which is something like this.

<?php
class Render {
    // Task 1 create public static displayDimensions function that accepts $size parameter
    public static function displayDimensions($size) {
      // Task 2 return string "length x width"
      return $size[0] . " x " . $size[1];
    }
}
?>

I hope it helps you to keep going and to better understand.