title: Initialize Global Variables in PHP
body: <p>Is it good practice to initialize a global variable in PHP? The snippet of code seems to work fine, but is it better to initialize (in a larger project, say for performance sake) the variable outside of a function, like in the second scratch of code?</p>
  
  <pre><code>if(isset($_POST["Return"]))Validate();
  function Validate(){
      (!empty($_POST["From"])&amp;&amp;!empty($_POST["Body"]))?Send_Email():Fuss();
  };
  function Send_Email(){
      global $Alert;
      $Alert="Lorem Ipsum";
      mail("","",$_POST["Body"],"From:".$_POST["From"]);
  };
  function Fuss(){
      global $Alert;
      $Alert="Dolor Sit"
  };
  
  function Alert(){
      global $Alert;
      if(!is_null($Alert))echo $Alert;
  };
  </code></pre>
  
  <p>Notice the variable $Alert above is not initialized.</p>
  
  <pre><code>$Alert;
  if(isset($_POST["Return"]))Validate();
  function Validate(){
      (!empty($_POST["From"])&amp;&amp;!empty($_POST["Body"]))?Send_Email():Fuss();
  };
  function Send_Email(){
      global $Alert;
      $Alert="Lorem Ipsum";
      mail("","",$_POST["Body"],"From:".$_POST["From"]);
  };
  function Fuss(){
      global $Alert;
      $Alert="Dolor Sit"
  };
  
  function Alert(){
      global $Alert;
      if(!is_null($Alert))echo $Alert;
  };
  </code></pre>
  
  <p>Now notice it is.</p>
  
  <p>I appreciate any answers! Thanks in advance, Jay</p>