Jump to content

run a js file as php


The Little Guy

Recommended Posts

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"

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.