title: Jquery loginAlert is not defined
body: <p>I'm trying to call a jquery function via php. </p>
  
  <p>In my PHP Pages head section I have :</p>
  
  <p><code>&lt;script src="login.js" type="text/javascript"&gt;&lt;/script&gt;</code></p>
  
  <p>this file contains:</p>
  
  <pre><code>$(document).ready(function() {
  
  function loginAlert() {
      alert ('Message when logging in');
  }
  
  });
  </code></pre>
  
  <p>Below this in the php pages head section I have:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
  &lt;?php if ($login === 1) { ?&gt;
      loginAlert();
  &lt;?php }  ?&gt;
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>When I load the page the chrome console shows:</p>
  
  <pre><code>jQuery.Deferred exception: loginAlert is not defined ReferenceError: loginAlert is not defined
  
  Uncaught ReferenceError: loginAlert is not defined
  </code></pre>
  
  <p>What am I doing wrong ?
  How can I call this function ?</p>