Ho將多行文本存儲在javascript變量中;將多行文本存儲在JavaScript變量中
我使用PHP爲JavaScript變量賦值。
請參考下面
<html>
<head>
<title> New Document </title>
<?php
$foo = " this is a
multiline statement";
?>
<script>
bar = '<?php print $foo;?>';
alert(bar);
</script>
</head>
<body>
</body>
</html>
樣本代碼,我不想失去任何空白characters.How才能做到這一點?
http://stackoverflow.com/questions的重複/ 168214/pass-a-php-string-to-a-javascript-variable-including-escaping-newlines看起來好像 – 2010-06-22 04:55:57