title: PHP/HTML - isset function
body: <p>I'm fairly new to PHP and am creating a website for my company. I am using some existing code that I have obtained but can't seem to make it work properly - any help would be much appreciated!</p>
  
  <p>I have a variable, <b>$id</b>, which identifies the product category type to display on the page. I first need to check that the id variable has been set and if not, default the variable to category 0.</p>
  
  <p>The code I have is as follows:</p>
  
  <pre><code>setdefault($id, 0);
  
  function setdefault(&amp;$var, $default="") 
  {
     if (!isset($var)) 
     {
        $var = $default;
     }
  }
  </code></pre>
  
  <p>So with the address www.website.com/browse.php, I would expect it to default to $id=0; with the address www.website.com/browse.php?id=3, I would expect it to set $id to 3 and display the relevant products. However, despite setting $id, it still defaults to 0. Is there something obviously incorrect with my code?</p>