我收到未终止的字符串文字错误。
content: '<div><p>
这是我用* .tpl文件编写的代码。代码用文档就绪函数编写。
content: '<div><?php echo strlen($gmap['onelinetext'])>0 ? $gmap['onelinetext'] : $gmap['maptext']; ?></div>'
当我从后端更新内容时,例如“14534 Mayfair Dr”它会填充错误。
有人可以指导我如何修复此错误。
此致
答案 0 :(得分:1)
根据您提供的信息,我假设PHP echo正在插入包含换行符的字符串。一种可能的解决方案是转义换行符或在PHP代码中替换它们“。”。
您需要的功能是str_replace。以下内容摘自PHP手册http://php.net/manual/en/function.str-replace.php
<?php
// Order of replacement
$str = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
$order = array("\r\n", "\n", "\r");
$replace = '<br />';
// Processes \r\n's first so they aren't converted twice.
$newstr = str_replace($order, $replace, $str);