title: Get user name from url and set as string. But its not returning anything
body: <p>I am trying to return the current username. I get the user name from the URL and access by <code>$_GET['user']</code> method.</p>
  
  <p>But when i try with the get method it will not return the name, instead its returning empty.  </p>
  
  <pre><code>echo $_GET['user']; // giving myname
  
  $userName=$_GET["user"];
  
  function getUserName()
  {
  global $userName;       
      if(isset($userName)){   
          return $userName;
      }else{
          return "defaultuser";
      }
  }
  </code></pre>
  
  <p>I tried this, too:<br>
  <code>$userName="".$_GET['user']."";</code></p>
  
  <p>But when I give simply <code>$userName="myname";</code> its working. So is there any problem in this line <code>$userName=$_GET["user"];</code>.</p>