megetron Posted January 22, 2012 Share Posted January 22, 2012 Hi, I have a file with a .js extension (I dont want to change the extensions because of other issues I have, wich are for another thread ). in this .JS file I want to execute some php commands. actually I want to generate using php a .js file. How do I do that? Link to comment https://forums.phpfreaks.com/topic/255511-how-do-i-force-js-to-be-execute-as-a-php-file/ Share on other sites More sharing options...
jcbones Posted January 23, 2012 Share Posted January 23, 2012 If it were me, I would change the ext to .php and use the header content-type to force it back to javascript. Alternatively you could make the server parse all .js files as PHP, which is horrible IMHO. Especially if you only have 1 file that needs parsing. .htaccess AddType application/x-httpd-php .js You may even have to make that: AddType application/x-httpd-php5 .js if you are on a host like GoDaddy Link to comment https://forums.phpfreaks.com/topic/255511-how-do-i-force-js-to-be-execute-as-a-php-file/#findComment-1310207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.