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 Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Random Fun with Arrays

Nathaniel Kolenberg
Nathaniel Kolenberg
12,836 Points

Why use $id as argument in function when not used inside function?

Hi everyone,

I'm a bit confused as to why $id is used as an argument within the get_item_html() function in this part. It's not being used in the body of the function and so I don't really understand the use of it.

I've removed it from my code and therefore also removed what we pass as parameter for the $id argument, and my example site works just like the teacher's.

Is there a specific reason to use the $id as an argument here? Am I missing something? Would appreciate any help in understanding this.

Thanks in advance!

4 Answers

jack AM
jack AM
2,618 Points

You're right, imo, that the $id is not needed. I looked forward into future videos just to see if it was left in there for some reason or another, and it's just not used as a stand alone variable. I personally would just disregard it, unless by chance I found it's use down the road.

Nathaniel Kolenberg
Nathaniel Kolenberg
12,836 Points

It appears that we indeed use the $id in a later video :)

Nathaniel Kolenberg
Nathaniel Kolenberg
12,836 Points

Thanks a lot for responding Jack. I'll disregard it for now as well unless I see it pop up again in a future vid.

Cheers!

N8

jack AM
jack AM
2,618 Points

hah, okay awesome. Glad that worked out :)