我收到未终止的字符串文字错误。
content: '<div><p>
这是我用 *.tpl 文件编写的代码。代码是用文档就绪函数编写的。
content: '<div><?php echo strlen($gmap['onelinetext'])>0 ? $gmap['onelinetext'] : $gmap['maptext']; ?></div>'
当我从后端更新内容时,例如“14534 Mayfair Dr”它会填充错误。
有人可以指导我如何解决此错误。
问候,
我收到未终止的字符串文字错误。
content: '<div><p>
这是我用 *.tpl 文件编写的代码。代码是用文档就绪函数编写的。
content: '<div><?php echo strlen($gmap['onelinetext'])>0 ? $gmap['onelinetext'] : $gmap['maptext']; ?></div>'
当我从后端更新内容时,例如“14534 Mayfair Dr”它会填充错误。
有人可以指导我如何解决此错误。
问候,
根据您提供的信息,我假设 PHP 回显正在插入一个包含换行符的字符串。一种可能的解决方案是
在 PHP 代码中转义换行符或替换它们 ' '。
您需要的功能是 str_replace。以下内容取自http://php.net/manual/en/function.str-replace.php的 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);