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"

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.