我有一个db的返回字符串.
返回字符串必须以javascript格式化.
<?php
$db = "this is a line
this is a new line";
?>
Run Code Online (Sandbox Code Playgroud)
我如何将上述内容转换为:
<?php $db = "this is a line \n this is a new line"; ?>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
<script>
var jdb = <?php echo $db; ?>
</script>
Run Code Online (Sandbox Code Playgroud)