Jump to content

Call external javascript file as a php file


scanreg

Recommended Posts

Hi

 

I'd like to call an external js file as a php file, something like:

 

<?php
<html><head>
<script language=”JavaScript” type=”text/javascript” src=”js.php”></script>
</head>
<body>
</body>
</html>
?>

 

I've tried making the js.php file like the following but I get a syntax error:

 

<?
Header(”content-type: application/x-javascript”);
$testvar=”Hat”;
echo “document.write(\”Item: <b>” . $testvar . “</b>\”)”;
?>

 

The error I get is:

 

<br />

<b>Parse error</b>:  syntax error, unexpected ':' in <b>/path/to/js/js.php</b> on line <b>2</b><br />

 

Any idea why it might be triggering this error?

 

Thanks :)

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.