如何将变量从php页面传递到javascript并显示数据
问题描述:
如何将存储在变量中的数据从php传递到javascript,并通过使用split函数,我们正在拆分数据并将其显示在网络时代....
how to pass the data which is stored in a variable from php to javascript and by using split function we are spliting the data and display it on the web age ....
答
冒着无语接听被大喊大叫的危险,今天我心情很宽裕:)
At the risk of being shouted at for answering without context, I'm in a generous mood today :)
<?php
//do lots of stuff in my PHP page
$var = 'somevalue';
?>
<html>
<head>
<title>My page title</title>
<script type='text/javascript'>
var myJsVar = '<?php echo $var;?>'
</script>
</head>
<body>
</body>
</html>