PHP Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Random Fun with Arrays

Nathaniel Kolenberg
Nathaniel Kolenberg
11,692 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
11,692 Points

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

Nathaniel Kolenberg
Nathaniel Kolenberg
11,692 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 :)