title: how to use php in javascript if statement
body: <p>I have the following code</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
    var needToConfirm = true;
  
    window.onbeforeunload = confirmExit;
    function confirmExit()
    {
      if (needToConfirm)
      {
  
        return  'Are you sure?';
  
  
       }
       else 
       return 'Continue';
    }
  </code></pre>
  
  <p>here needToConfirm is just a flag/a variable. What I want, is to insert a php statement in the if condition and execute the php statement when the condition is true. Can anyone help me??</p>