Reputation: 5309
I am extending FPDF and want to include some external variables but it's not working. What am I doing wrong?
<?php
class PDF extends FPDF {
public var $DocNum;
public var $cliente;
public var $noCliente;
public var $noTienda;
public var $noPedido;
function Header() {
$this->Image('fpdf/cabMCR.jpg',5,10,100,0,'JPG','');
$this->SetFont('Arial','B','16');
$this->SetXY(125,15);
$this->Write(5,'FACTURA');
// doing some more stuff here
}
function Footer() {
$this->SetTextColor(150,150,150);
$this->SetXY(10,285);
$this->SetFont('Helvetica','I',7);
$this->Write (5, 'MCR Electronic S.L. Inscrita en el Registro Mercantil de Madrid en Tomo 15819, folio 163, Seccion 8ª, hoja M-267058, CIF: B82766452');
$this->SetTextColor(0,0,0);
}
}
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage('P');
$pdf->SetDisplayMode(real,'default');
$pdf->SetAuthor('Company S.L');
$pdf->SetTitle('Factura MCR');
$pdf->$DocNum = $DocNum;
$pdf->$cliente = $cliente;
$pdf->$noCliente = $noCliente;
$pdf->$noTienda = $noTienda;
$pdf->$noPedido = $noPedido;
?>
Upvotes: 0
Views: 378
Reputation: 513
You are doing it wrong! Should be like this:
$pdf->DocNum = $DocNum;
$pdf->cliente = $cliente;
$pdf->noCliente = $noCliente;
$pdf->noTienda = $noTienda;
$pdf->noPedido = $noPedido;
Suerte!
Upvotes: 0
Reputation: 15443
You don't want to reference class members with a $ unless you're doing something kind of strange with variable variables.
Instead of this:
$pdf->DocNum = $DocNum;
$pdf->$cliente = $cliente;
$pdf->$noCliente = $noCliente;
$pdf->$noTienda = $noTienda;
$pdf->$noPedido = $noPedido;
It should be more like this:
$pdf->DocNum = 'somevalue';
$pdf->cliente = 'somevalue';
$pdf->noCliente = 'somevalue';
$pdf->noTienda = 'somevalue';
$pdf->noPedido = 'somevalue';
Upvotes: 3