问题描述
是否应该在包含在.php
文件中的.js文件中看到PHP变量?
我有一个客户端javascript代码存储在.js文件中,包含
到PHP文件中使用
< script src =" filename.js>< / script>
此代码初始化一个Javascript变量
var u =" string";
字符串应该是值$ HTTP_HOST
所以,当初始化这个变量时
var u =<? echo $ HTTP_HOST;?> ;;
我引用了javascript消息语法错误
我做错了什么,或PHP变量是没有在包含js
文件中看到?
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.js></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?
推荐答案
的值
这篇关于是否应该在包含在.php文件中的.js文件中看到PHP变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!