我正在使用tFPDF类。将变量传递给扩展另一个类的类
我正在使用此代码来获得自定义扩展此类页眉和页脚
class PDF extends tFPDF{
function Header(){
$this->Image('../../images/logo-admin.png',10,6,30);
$this->SetFont('DejaVu','',13);
$this->Cell(247,10,$produto,0,0,'C',false);
$this->SetDrawColor(0,153,204);
$this->SetFillColor(98,197,230);
$this->SetTextColor(255);
$this->Cell(30,10,date('d/m/Y'),1,0,'C',true);
$this->Ln(20);
}
function Footer(){
$this->SetY(-15);
$this->SetFont('Arial','',8);
$this->Cell(0,10,'P'.chr(225).'gina '.$this->PageNo().'/{nb}',0,0,'C');
}
}
我需要做的,是与不属于类的变量在某种程度上改变$produto
。
我打电话给这个班,使用$pdf = new PDF();
。
我如何可以传递一个变量这一类,所以我可以使用一个字符串,像$pdf = new PDF('SomeString');
,并用它里面的类象$this->somestring = $somestringfromoutside
构造函数有什么问题? – 2012-07-25 15:30:54