The Little Guy Posted March 18, 2010 Share Posted March 18, 2010 I can not remember how to do this, but I would like to have php parse only one js file, how can I do that? Quote Link to comment https://forums.phpfreaks.com/topic/195718-run-a-js-file-as-php/ Share on other sites More sharing options...
oni-kun Posted March 19, 2010 Share Posted March 19, 2010 I can not remember how to do this, but I would like to have php parse only one js file, how can I do that? AddType application/x-httpd-php .jsphp You can keep it a .js if you'd like, but making a new extension for PHP included JS should really be in a separate format, all that would be required is renaming your javascript file you wish to be parsed to ".jsphp" Quote Link to comment https://forums.phpfreaks.com/topic/195718-run-a-js-file-as-php/#findComment-1028475 Share on other sites More sharing options...
The Little Guy Posted March 19, 2010 Author Share Posted March 19, 2010 Here is what I did: Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^connect.js$ connect.php [NC,L] but when I run the following code I get a javascript error: <?php header("Content-Type: text/javascript"); include 'incl/php/incl.php'; echo 'doucment.write("'.addslashes(print_r($_SERVER, true)).'");'; ?> Resource interpreted as other but transferred with MIME type text/javascript. umok.us/connect.js:1Uncaught SyntaxError: Unexpected token ILLEGAL Quote Link to comment https://forums.phpfreaks.com/topic/195718-run-a-js-file-as-php/#findComment-1028714 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.