【发布时间】:2015-04-03 17:05:54
【问题描述】:
Class Html_Pdf_Export {
var $first_name;
var $last_name;
//alot of data variables
//How I have it now
function getHtml()
{
$html = "<!DOCTYPE html>
1000 lines of code with data variables
</html>";
$this->html = $html;
return $this->html;
}
function convertToPdf()
{
//function that converts $this->html to Pdf
}
//How I want the function to be but How do I pass all the data variables?
function loadHtml()
{
$html_load_template = new Html_Load_Template('the_template_i_want_to_load_with_data_variables');
$this->html = $html_load_template;
return $this->html;
}
}
我有一个将 Html 转换为 PDF 的类。我在该类中的 html 包含 1000-1500 行最终转换为 PDF 的 html 代码。为了让它不那么臃肿,我决定将所有的 html 分离到另一个名为 Html_Load_Template 的类中。如何将 Html_Pdf_Export 具有的所有数据变量传递给 Html_Load_Template 类?
谢谢
【问题讨论】:
标签: php html oop templating