javascript 中是否可以读取到php值? 不可以直接调用 php代码先执行JS代码后执行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php $x = "hello";?>aa.js的内容document.write("<?=$x?>"); bb.php:<?php $x = "hello"; ?> <script type="text/javascript" src="aa.js"> </script>aa.js的内容 document.write(" <?=$x?>"); 我是想把这个值设在js中设置成变量 即 var ff= php值 不知道是否可以实现 <?php $intCom=5;?>在js中:var intCom=document.write(<?php echo $intCom;?>) 抱歉,上面的有点问题正确方法:<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title></head><body><?php $jsj='23';?><SCRIPT LNAGUAGE=JAVASCRIPT> var t=<?php echo $jsj;?> //t='23' alert(t);</script> </body></html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档 </title> </head> <body> <?php $x='nihao'; ?> <SCRIPT LNAGUAGE=JAVASCRIPT> var ff="<?=$x?>"; alert(ff); </script> </body> </html> 我测试有值啊你怎么说没值哦? 这们的问题一天,都有很多人问了,var ff="<?=$x?>"; 这是标准的用法. 问题已经解决,各位没有仔细看我的问题,我说的是用<script></script>引用JS文件这和chinmo兄弟的方式是不同的,chinmo的方式是在一个.php文件下面,这样的话你的方式是没有问题的,而使用<script>的方式在js文件当中是无效的,这是和apache的配置有关系的,最后解决的方法是使用dom js setInterval this与getelement..怎么不行..? 我想制作一个时间到了自动提交的程序!希望各位大侠帮我! 以一百分征求一段下拉菜单的代码?拜谢!! 怎样判断多选按钮是否已被选中? 关于关闭窗口的问题! 如何用语言判断某个页面是否存在? 求一段代码!!很急,谢谢了! 一个关于选择按钮的问题??? Synchronous XMLHttpRequest on the main thread is deprecated because of its detr 遇到数字就再后面加<br> 如何输出一个网站的所有cookies(用js和asp)
$x = "hello";
?>aa.js的内容
document.write("<?=$x?>");
<?php
$x = "hello";
?>
<script type="text/javascript" src="aa.js"> </script>aa.js的内容
document.write(" <?=$x?>");
$intCom=5;
?>
在js中:
var intCom=document.write(<?php echo $intCom;?>)
正确方法:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<?php
$jsj='23';
?>
<SCRIPT LNAGUAGE=JAVASCRIPT>
var t=<?php echo $jsj;?> //t='23'
alert(t);
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档 </title>
</head>
<body>
<?php
$x='nihao';
?>
<SCRIPT LNAGUAGE=JAVASCRIPT>
var ff="<?=$x?>";
alert(ff);
</script>
</body>
</html>
我测试有值啊
你怎么说没值哦?