title: Using external js with .php extension in Codeigniter
body: <p>I am using codeigniter 2 and I have my theme folder consist of <strong>js</strong>, <strong>img</strong>, <strong>css</strong> folders.</p>
  
  <p>Inside <strong>js</strong> folder, file name is <strong>js_functions.php</strong> contains:</p>
  
  <pre><code>&lt;?php header("Content-type: text/javascript"); ?&gt;
  /**
   * GLOBAL VARIABLES &amp; PATHS
   *
   * path definitions for jquery inline usage
   *
   */     
  var base_url         = '&lt;?=base_url();?&gt;';
  // ------------------------------------------------------------------------
  
  /**
   * jquery.message Global Implementation
   *
   * Shows message if any session flashdata named message is set
   *
   */
  
  &lt;?php if($this-&gt;session-&gt;flashdata('message')):?&gt;
  $(function() { $().message("&lt;?=$this-&gt;session-&gt;flashdata('message');?&gt;"); });
  &lt;?php endif; ?&gt;
  
  // ------------------------------------------------------------------------
  </code></pre>
  
  <p>and, calling in it <strong>view</strong> file</p>
  
  <pre><code>&lt;script type="text/javascript" src="&lt;?=base_url();?&gt;themes/admin/js/js_functions.php"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>renders correctly. But it returns in the chrome's inspect screen: </p>
  
  <pre><code>var base_url         = '&lt;br /&gt;
  Uncaught SyntaxError: Unexpected token ILLEGAL
  </code></pre>
  
  <p>and in the browser when you call the page from address bar:</p>
  
  <pre><code>var base_url         = '&lt;br /&gt;
  &lt;b&gt;Fatal error&lt;/b&gt;:  Call to undefined function base_url() in &lt;b&gt;F:\xampp\htdocs\themes\js\js_functions.php&lt;/b&gt; on line &lt;b&gt;11&lt;/b&gt;&lt;br /&gt;
  </code></pre>
  
  <p>What's wrong? Isn't it the correct way of using php in external js/php file?</p>