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 Enhancing a Simple PHP Application Refactoring the Codebase Separating Concerns: Models

Zach Minot
Zach Minot
6,182 Points

Separating Concerns

This code creates an array of ice cream flavors and then displays them in an index.php file. However, we now also need the array of ice cream flavors in another file. Let's move the flavors array into a model file. First, in flavors.php, create a new function called get_all_flavors().

Tried everything, cannot get this to work. Anyone know the correct code for it?

Zach Minot
Zach Minot
6,182 Points

Never mind solved it!

3 Answers

Zach Minot
Zach Minot
6,182 Points

This is just asking for you to create a new, empty function in flavors.php. Remember the syntax of creating a new function is this:

function function_name (argument, if necessary) {code to be executed};

so, if I wanted to make a new, empty function named HelloWorld:

function HelloWorld(){};

Zack, Post your solve. I am having trouble figuring it out.

Thank you. I was putting an = sign after function that did not need to be there.