title: PHP GET Question: How do I set a variable value only if it's not in the query string?
body: <p>I know how to get the value from the query string if the parameter exists:</p>
  
  <pre><code>$hop = $_GET['hop'];
  </code></pre>
  
  <p>But I also need to set a default value IF it's not in the query string. I tried this and it didn't work:</p>
  
  <pre><code>$hop = $_GET['hop'];
  
  if ($hop = " ") {
    $hop = 'hardvalue';
  };
  </code></pre>
  
  <p>Please help me handle the case where the query string has and does not have the "hop" parameter, and if it's present but not defined:</p>
  
  <pre><code>example.com/?hop=xyz
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>example.com/
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>example.com/?hop=
  </code></pre>
  
  <p>PS I don't know what I'm doing, so if you explain to me, please also include the exact code for me to add to my PHP page. </p>