1,js中使用php变量
<?php $userid = 1;?> //此处userid是调取过来的,我是为了让大家明白给它赋值了;
<a id="denglu">我要投诉</a>
<script type="text/javascript">var btn = document.getElementById('denglu');var userid = <?=$userid?>; //此处为取得上方php值btn.onclick = function () {if (userid > 0){window.location.href='index.php?g=Member&m=Tousu&a=index';}else {alert('请先登录');}}</script>
2,php中使用js
<?php$a="aaa";echo "<script>alert('你好');location.href='mail.php?username=".$a."';</script>";?>
