I have a JavaScript file where I would like to include some php code. The problem is that I have a few defines on PHP that I would like to use on JS as well.
Is there any way of including a .js file in HTML allowing the server to first interpret it (before downloading to the client) using php?
Thanks :)
In
file.php
you'll also want to output the correct header, before outputting anything you should have the following:EDIT: As @Tony_A pointed out, it should be
application/javascript
. I don't think it mattered as much when I wrote this post in 2010 :)