我在php中有一个变量
$test = "This is a string
It has multiple lines
there are three total" ;
(从文本区域输出)
我想将此变量传递给 javascript 函数
我已经把这个写在我的 php 文件里了
<?php echo "<script language=javascript>convert('$test');</script>"; ?>
但这会产生错误“未终止的字符串文字”我该如何解决这个问题??
最佳答案
尝试
$test = "This is a string\nIt has multiple lines\nthere are three total";
关于php - 如何将多行字符串传递给 javascript 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5868800/