title: PHP variable "default value"
body: <p>I want to get a value from the session, but use a default if it is not defined. And ofcourse I want to circumvent the PHP notice.</p>
  <p>You can write a function that does this</p>
  <pre><code>function get(&amp;$var, $default){
      if(isset($var)) return $var;
      return $default;
  }
  
  echo get($foo, &quot;bar\n&quot;);
  $foobar = &quot;foobar&quot;;
  echo get($foobar, &quot;ERROR&quot;);
  </code></pre>
  <p><a href="http://codepad.org/FzTPuvBO" rel="nofollow noreferrer">Example in action</a></p>
  <p>Is there a way to do this without defining this function in every file?</p>