Is a PHP variable supposed to be seen in a .js file included into a .php
file?
I have a client side javascript code stored in a .js file which is included
into a PHP file using
<script src="filename.j s></script>
This code initialises a Javascript variable
var u="string";
The string is supposed to be the value of $HTTP_HOST
So, when initialise this variable like
var u=<? echo $HTTP_HOST;?>;
I sterted getting a javascript message Syntax Error
Am I doing something wrong, or PHP variables are not seen in included js
files?
file?
I have a client side javascript code stored in a .js file which is included
into a PHP file using
<script src="filename.j s></script>
This code initialises a Javascript variable
var u="string";
The string is supposed to be the value of $HTTP_HOST
So, when initialise this variable like
var u=<? echo $HTTP_HOST;?>;
I sterted getting a javascript message Syntax Error
Am I doing something wrong, or PHP variables are not seen in included js
files?
Comment