title: How to inject javascript code dynamically before body tag using php?
body: <p>Ｉam using a custom mvc framework that i built myself. I would like to ask how can we dynamically include javascript files to the bottom of my page?</p>
  
  <p>Create Account Page (createaccount.php)</p>
  
  <pre><code>&lt;?php include('header.php'); ?&gt;
  
  &lt;div class="container maincontainer"&gt;
  &lt;h3&gt;Create an Account &lt;/h3&gt;
  
  &lt;?php include('footer.php'); ?&gt;
  </code></pre>
  
  <p>My  tag is in the footer.php.</p>
  
  <p>I have another page called </p>
  
  <p>Login Page (login.php)</p>
  
  <pre><code>&lt;?php include('header.php'); ?&gt;
  
  &lt;div class="container maincontainer"&gt;
  &lt;h3&gt;Login &lt;/h3&gt;
  
  &lt;?php include('footer.php'); ?&gt;
  </code></pre>
  
  <p>Basically, this 2 pages use different javascript files. I want to include different js for different page. Note：they are using same footer.php file</p>
  
  <p>Is there any function/method that i can write to inject js code dynamically to the footer.php based on specific pages? Advice from experts appreciated greatly!</p>
  
  <p>Cheers</p>