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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Aruna Srinivasiah](https://secure.gravatar.com/avatar/f2ab1a907a8b2be30ccba824a12e6b68?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Aruna Srinivasiah
Courses Plus Student 598 PointsHow do I create an object with some data?
Does the name, flavor, and record go as arguments?
<?php
class Fish {
public $common_name;
public $flavor;
public $record_weight;
}
$bass = new Fish("Largemouth Bass", "Excellent", "22 pounds 5 ounces");
?>
2 Answers
![Jennifer Nordell](https://uploads.teamtreehouse.com/production/profile-photos/5432702/micro_jen-square.jpg)
Jennifer Nordell
Treehouse TeacherHi there! No, the properties aren't set using an initializer so they do not go in as arguments. You will be accessing the properties of the new object directly. Let me see if I can give you another example which might allow you to extrapolate the answer.
<?php
class Person {
public $first_name;
public $last_name;
public $treehouse_student;
}
$jennifer = new Person();
$jennifer->first_name = "Jennifer"
?>
Each property will be accessed individually and set to the values corresponding to what is found in the challenge instructions. Good luck, but let me know if you're still stuck!
![Martin Balon](https://uploads.teamtreehouse.com/production/profile-photos/1919402/micro_Untitledd.jpg)
Martin Balon
43,651 PointsHi Aruna, if you want to create an object like this you need to modify your class so it accepts arguments. The code should look like this:
<?php
class Fish($name, $flavor, $record)
{
public $this->common_name = $name;
public $this->flavor = $flavor;
public $this->record_weight = $record;
}
$bass = new Fish("Largemouth Bass", "Excellent", "22 pounds 5 ounces");
?>