title: php claims my defined variable is undefined
body: <p>My php is a little rusty but this is boggling my mind right now. I googled this and read all the stackoverflow questions I could find that looked related, but those all seemed to have legitimate undefined variables in them. That leads me to believe that mine is the same problem, but no amount of staring at the simple bit of code I have reduced this to seems to get me anywhere. Please someone give me my dunce cap and tell me what I did wrong!</p>
  <pre><code>&lt;?php
  //test for damn undefined variable error
  
  $msgs = &quot;&quot;;
  
  function add_msg($msg){
    $msgs .= &quot;&lt;div&gt;$msg&lt;/div&gt;&quot;;
  }
  function print_msgs(){
    print $msgs;
  }
  
  add_msg(&quot;test&quot;);
  add_msg(&quot;test2&quot;);
  print_msgs();
  ?&gt;
  </code></pre>
  <p>This gives me the following, maddening output:</p>
  <blockquote>
  <p>Notice: Undefined variable: msgs in C:\wamp\www\fgwl\php-lib\fgwlshared.php on line 7</p>
  <p>Notice: Undefined variable: msgs in C:\wamp\www\fgwl\php-lib\fgwlshared.php on line 7</p>
  <p>Notice: Undefined variable: msgs in C:\wamp\www\fgwl\php-lib\fgwlshared.php on line 10</p>
  </blockquote>
  <p>Yes, this is supposed to be a shared file, but at the moment I have stripped it down to just what I pasted. Any ideas?</p>