Reputation: 309
So far no luck experimenting. I need to run a php function to check a header (from my understanding not possible through js), but the page needs to be a .js as it is being access by other pages as and it was requested to keep it like that.
I won't be to shaken up if I can't run PHP directly in the page though, theres always other ways. I just wanted to see if there was a simple way.
EDIT: This is all run on a server. Sorry, I didn't clarify that. (not this big of a noob mistake)
Upvotes: 1
Views: 1965
Reputation: 24506
If you're using Apache, adding the line AddType application/x-httpd-php .js
in your .htaccess
file will set .js
files to be processed as PHP.
Upvotes: 2
Reputation: 8963
Edit .htaccess file to
AddType application/x-httpd-php .js
AddHandler x-httpd-php5 .js
<FilesMatch "\.(js|php)$">
SetHandler application/x-httpd-php
</FilesMatch>
Then you can run PHP in a js file.
Upvotes: 6