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行的HTML代碼,最終轉換爲PDF。爲了減少臃腫,我決定將所有html分離到另一個名爲Html_Load_Template的類。如何將Html_Pdf_Export具有的所有數據變量傳遞給類Html_Load_Template?類功能正在加載顯示爲變數的HTML頁面
謝謝
哦, AdamM有同樣的想法。 :) – Sunny 2015-04-03 17:40:19