title: Shorthand conditional to define a variable based on the existence of another variable in PHP
body: <p>Essentially, I'd love to be able to define a variable as one thing unless that thing doesn't exist. I swear that somewhere I saw a shorthand conditional that looked something like this:</p>
  
  <pre><code>$var=$_GET["var"] || "default";
  </code></pre>
  
  <p>But I can't find any documentation to do this right, and honestly it might have been JS or ASP or something where I saw it.</p>
  
  <p>I understand that all that should be happening in the above code is just to check if either statement returns true. But I thought I saw someone do something that essentially defined a default if the first failed. Is this something anyone knows about and can help me? Am I crazy? It just seems redundant to say:</p>
  
  <pre><code>$var=($_GET["var"]) ? $_GET["var"] : "default";
  </code></pre>
  
  <p>or especially redundant to say:</p>
  
  <pre><code>if ($_GET["var"]) { $var=$_GET["var"]; } else { $var="default"; }
  </code></pre>
  
  <p>Thoughts?</p>