| 本帖最后由 lsok 于 2012-7-17 15:55 编辑 
 大家好:手册读到这一节,请问红字部分是什么意思?如何使用?
 $this->parser->parse()这个方法接收一个模板名和数据数组作为输入,生成一个解析过的版本。例如:
 $this->load->library('parser');
 
 $data = array(
 'blog_title' => 'My Blog Title',
 'blog_heading' => 'My Blog Heading'
 );
 
 $this->parser->parse('blog_template', $data);第一个参数包含[url=]视图[/url]文件的文件名(在这个例子中是blog_template.php),第二个参数包含一个用于模板替换的相关数组。 在上面的例子中,这个模板包含两个变量:{blog_title} 和 {blog_heading}
 
 不用“echo”或处理$this->parser->parse()返回的数据。他会自动传送数据到output类最终输出到浏览器。然而,如果你想返回数据而不是发送到output类,你可以使用TRUE(布尔值)作为第三个参数。$string = $this->parser->parse('blog_template', $data, TRUE); 
 $this->parser->parse_string()This method works exactly like parse(), only accepts a string as the first parameter in place of a view file.
 
 
 
 |