title: Generate JavaScript file with PHP when requested in HTML
body: <p>How do I Generate a JavaScript file with PHP when it is requested in an HTML program?  I want a PHP program like this that runs on the server when a certain JavaScript file is requested.  Example code:</p>
  
  <pre><code>&lt;?php
      If (requested("file:///C:/server/htdocs/javascriptgenerator.php") {
          javascript-code-to-give-to-client = "function myFunction(){...";
      }
  ?&gt;
  </code></pre>
  
  <p>I know that was very fake code, but that is how I write when I don't know how to do it.  I would also want this file to always be running on the server in case the file is requested.  I also want to know how to just send the file as normal.  I also want to know how to do this depending on the client.</p>