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!

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 Populating the Recipes

Observation RE: addTag();

This is just an observation.

When we add a tag to a recipe, we have it set-up singular to add one tag at a time.

public function addTag($tag)
        $this->tags[] = strtolower($tag);

But the recipes Alena provided us with to populate the recipes have several tags, and are not comma separated. A few examples....

$belgian_waffles->addTag("breakfast, quick bread");
$granola_muffins->addTag("breakfast, snack, quick bread");

For me personally, this will cause problems in the future lessons when displaying the Recipe Titles that are filtered by a tag. For example, to find the belgian waffles recipe using a tag filter, you would need to add the argument as "breakfast, quick bread" instead of just "breakfast" for example.

I look forward to receiving your insight on this. Is there a reason I am overlooking?

Thanks in advance!

1 Answer

I haven't done it myself so not overly sure but I think the commas found in

$belgian_waffles->addTag("breakfast, quick bread");

are used to add new items to the array. In this case two items, breakfast and quick bread, are being added to the array.