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

Building the Recipe "Please enter valid measurement"

Hi i just finished the chapter "Building the Recipe" where we add the predefined recipes found in "inc/allrecipes.php". How ever no matter what recipe i use with the final code all i get returned is "Please enter a valid measurement: tsb, tbsp, cup, oz, lb, fl oz, pint, quart, gallon". Now the code worked when recipes where added manually through out the course only after including the "inc/allrecipes.php" does this error show up. anybody else experience this ?

Update, checked all the basics and tried passing in a value of "null" into the render method as so:

Render::displayRecipe(null);

Still returns "Please enter a valid measurement: tsb, tbsp, cup, oz, lb, fl oz, pint, quart, gallon".

I have tried using "var_dump" on several of the recipe objects but get nothing in return, any idea what could be wrong ?

2 Answers

David Tomko
David Tomko
7,744 Points

SOLVED Hey ik this might be a little bit late but I was having the same issue! All I had to do was in the second if statement in the addIngredient function was change the $measure = !null to $measure = null and now it works fine.

This is very late to answer this one but if anyone else encounters it now, mine was due to there being a unit missing from the measurements array, I added in the "oz" measurement that was present in the downloads file and all started working!