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 (Retired) Properties and Methods Mid-Course Challenge

Create a Fish object named $bass with the following data: name: "Largemouth Bass" flavor: "Excellent"

This question is vague, does anybody know what they are asking?

fish.php
<?php

 class Fish {
  public $common_name;
  public $flavor;
  public $record_weight;

  function Fish($name, $flavor, $record){


    $this->common_name = $name;
    $this->flavor = $flavor;
    $this->record_weight = $record;

  }

   $bass = new fish(
     $common_name = "Largemouth Bass";
     $flavor = "Excellent";
     $record_weight = "22 pounds 5 ounces";

   );

}



?>

2 Answers

Julian Aramburu
Julian Aramburu
11,368 Points

Hi Steve! In that particular challenge you are supposed to use the constructor you just created to create a new instance of Fish. In this case the correct answer would be:

$bass = new Fish("Largemouth Bass", "Excellent", "22 pounds 5 ounces");

Since in the constructor you defined 3 parameter being name, flavor and record(weight).

Thanks very much Julian. Sorry about the delay in my response, I was busy doing a CSS track.

Julian Aramburu
Julian Aramburu
11,368 Points

Cool I was able to help :)! Keep Coding!