PHP Build a Basic PHP Website Listing and Sorting Inventory Items Creating the Display Function

issue Using varies in funciton.php

Why use two varies instead for one vary because i saw don't use $id

<?php function get_item_html($id,$item){

$output = "<li><a href='#'><img src='" .$item["img"]."' alt='" .$item["title"]."' />" ."<p>View Detials</p>" ."</a></li>"; return $output;


1 Answer

Damien Watson
Damien Watson
27,300 Points


You are correct in saying you don't need to pass the $id because you are not using it. I could be wrong but I would say in this instance she is including it for future use, or incase she needs to reference it down the track.

This would allow you to do something like set the id to the list item. Meaning that clicking the item would give you access to the parents id. Or putting it on the anchor tag even.

  function get_item_html($id,$item){
  $output = "<li id='".$id."'><a href='#'><img src='"
    .$item["img"]."' alt='" .$item["title"]."' />"
    ."<p>View Detials</p>" ."</a></li>";
  return $output;