...

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



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

GJay
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
</Files>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum