- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些从 Zend_Form
生成的 HTML 数据。
我想将其附加到 div#wrapper
元素,但我的尝试引发了错误:未终止的字符串文字
。
我应该做什么来修复它?
注意:好吧,每个人看起来都假设我忘记在我的代码上添加 php 标签,但事实并非如此。这是我的“真实”代码
<?php
class Admin_Elements_Dialog {
private $_name;
private $_title;
private $_action;
private $_button = null;
private $_content;
private $_options = array();
public function __construct($options) {
$this->_options = $options;
}
public function setName($name) {
$this->_name = $name;
return $this;
}
public function setTitle($title) {
$this->_title = $title;
return $this;
}
public function setAction($action) {
$this->_action = $action;
return $this;
}
public function setOpener($button) {
if ($button instanceof Admin_Elements_Buttons)
$this->_button = $button;
return $this;
}
public function setContent($content) {
$this->_content = $content;
return $this;
}
public function renderScript() {
$html = array();
$html[] = '$(document).ready(function() {
$("body").append(\'<div id="' . $this->_name . '" title="' . $this->_title . '" class="ui-helper-hidden">' . $this->_content . '</div>\');
var dialog = $("#' . $this->_name . '").dialog(' . Zend_Json::encode($this->_options, false, array('enableJsonExprFinder' => true)) . ');
$("#' . $this->_button->getId() . '").click(function() {
$("#' . $this->_name . '").dialog("open");
return false;
});
});';
$html[] = '';
return join($html, PHP_EOL);
}
}
?>
最佳答案
您正在 Javascript 中使用 PHP 连接运算符 .
。
Javascript 的连接运算符是 +
:
$(document).ready(function() {
$("div#wrapper").append('<div id="dialog" title="Add new blog">' + <?php echo $this->form->render() ?> + '</div>');
});
此外,PHP 代码会逐字插入到您的页面中。如果 $this->form->render()
没有生成字面上引号封装的字符串,则生成的 Javascript 将无效。
你可能的意思是:
$(document).ready(function() {
$("div#wrapper").append('<div id="dialog" title="Add new blog"><?php echo $this->form->render() ?></div>');
});
但肯定有更好的方法。这样,您就必须留意可转义的字符和换行符。
而且,我无法抗拒:这是“提前致谢”;没有尾随“d”。
关于php - 错误: Unterminated string literal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6293663/
这是我在试验 JS 时的最新发现: (function() { return this; }).call('string literal'); // => [String: 'string liter
在 C 中有没有一种方法可以使用宏从字 rune 字创建字符串文字? 比如我有 'a' 我想创建字符串文字 "a" 澄清问题: #define A 'a' write(fd, "x=" CHAR2ST
令我困扰的是为什么术语“literal”被用来指代NSString和NSArray等类的实例。我只看到了用于引用 NSString 的术语,并且天真地认为它与“字面上”是一个字符串(位于引号之间)有关
我有以下使用 smarty 模板引擎的代码 在 php 文件中: $smarty->assign('SITE_URL', 'http://localhost/mis/'); 在 tpl 文件中:
我正在使用 regex101 tool 制作正则表达式并在解释字段中阅读 [.] - 文字字符 .[\.] - 匹配字符 .字面上地 我在“字面字符”和“字面字符”之间迷失了方向。 这两者有什么区别?
这个问题在这里已经有了答案: Single quotes vs. double quotes in C or C++ (15 个答案) 关闭 4 年前。 我正在阅读一本讨论“字 rune 字”与“字
浮点文字 float x = 3.2f; 的直接赋值和隐式转换为 float 的 double 之间的位表示是否存在差异 float x2 = 3.2;? 即是 #define EQUAL(FLOAT
这个极其简单的 Rust 程序: fn main() { let c = "hello"; println!(c); } 抛出以下编译时错误: error: expected a li
这个极其简单的 Rust 程序: fn main() { let c = "hello"; println!(c); } 抛出以下编译时错误: error: expected a li
是否有单行,类型 mapfilter ... es5+ higherfunction 或 ...?希望解决方案描述如何以及为什么和引用。如果有人知道为什么曾经不起作用。 timeTableKeys:是
我有包含这些声明的代码: class IRealNetDll; extern "C"__declspec(dllexport) IRealNetDll * CreateRealInstance(int
我有一个用于我们的一些服务的 SOAP 服务器 API,其中一位客户说他们不会与不提供至少 WS-I 基本配置文件合规性绑定(bind)的服务集成。 那么,问题是任何版本的 Delphi 都支持 Do
我已经尝试使用这两个循环以及列表理解。即使我正在尝试将数字转换为列表中的整型,两者都无法解析整数。
在代码中隐藏文字值的主要现有方法是什么,以便仅使用 hexdumper 或反编译器不容易跟踪它们? 例如,而不是编码: static final int MY_VALUE = 100; 我们可
我正在尝试使用文字来匹配 Empty Guid,但我不知道这里发生了什么: let [] EmptyGuid = System.Guid () let someFunction () = System
我正在尝试搜索 [Panels] like "*,*" 在工作表中,不幸的是,它没有准确检索该字符串,而是检索如下内容: [Panels] like "*blah,*" [Panels] like "
我看不出自然语言编程和文学编程之间的区别。如果有人解释,我将不胜感激。 最佳答案 Natural language programming是一种以近似于人类书写或说话的语言的形式向计算机表达指令的
我想从字符串数组中初始化一个 pydantic 文字 from typing import Literal from pydantic import BaseModel CLASS_NAME_VALU
我正在尝试在代码后面编写我的js代码。我定义了一个名为“contentPie”的文字,然后将 javascript 代码放入其文本中。但这不起作用。 contentPie.Text = "window
我有一个简单的数据集,可以使用如下行进行解析: R1 (a/30) to R2 (b/30), metric 30 我需要从上面得到的唯一数据如下: R1, a, 30, R2, 192.168.0.
我是一名优秀的程序员,十分优秀!