View Full Version : Can I put PHP code inside Javascript .js file?

01-10-2006, 07:13 PM
I have a javascript .js file, can I have php code like <?=$myvar;?> inside the .js file? will it work?
many thanks.

01-10-2006, 07:48 PM
If your server is set to parse .js as php, then yes.
Otherwise, you can change the filename to .php and that will work too...

Velox Letum
01-10-2006, 08:11 PM
Either will work, as long as it's parsed. Example .htaccess:

<Files file.js>
ForceType application/x-httpd-php