(1)
$serial_number=1;
echo "<script>var a=$serial_number;alert(a);</script>";
?>
(2)
$serial_number=1;
echo "<script>var a=$serial_number;alert("我是"+a+“朋友”);</script>";
?>
(1)弹框输出:1
(2)无结果,没有提示错误
请问,原因是什么,怎么解决?
php中连接字符串用".",不是"+"
呵呵,我看错了,你把alert("我是"+a+“朋友”)中的”“改成‘’
echo "<script type='text/javascript'>var a=$serial_number;alert(\"我是\"+a+\"朋友\");</script>";
echo "<script type='text/javascript'>var a=$serial_number;alert(\"我是\"+a+\"朋友\");</script>";
呵呵,我看错了,你把alert("我是"+a+“朋友”)中的”“改成‘’
$serial_number = 'wang gang';echo "<script type='text/javascript'>var a='$serial_number';alert('我是' + a + '朋友');</script>";
$serial_number = 'wang gang';echo "<script type='text/javascript'>var a='$serial_number';alert('我是' + a + '朋友');</script>";