From: "Angus Mann" on
Hi all. Whilst this question relates to fpdf (www.fpdf.org) I think it really is a PHP question, because it involves passing values into classes and functions.

Here's the problem .. I need to pass a PHP variable like $number into the header of a PDF.
I have extended the FPDF class as follows....

class PDF extends FPDF{
function Header(){
$this->SetFont('Arial','BU',12);
$this->Cell(0,5,'User notes for invoice number '.$number,0,'1','L');
}
}

The problem is, I can't figure out how to pass a value from the rest of the PHP script so it can be seen within the function above.

I'm sure the problem is one of the scope of the variable but this sort of thing is new to me and I can't figure out the syntax to make it work.

Before anybody suggests something like ...
function Header($number){}
Please recognize that the Header function is called automatically by FPDF and not by my code, so unless I totally hack the FPDF class I can't do this easily.

Any suggestions please?

From: "Angus Mann" on

----- Original Message -----
From: "Angus Mann" <angusmann(a)pobox.com>
To: "php-general" <php-general(a)lists.php.net>
Sent: Monday, April 26, 2010 2:46 PM
Subject: [PHP] FPDF passing values into header and footer?


Hi all. Whilst this question relates to fpdf (www.fpdf.org) I think it
really is a PHP question, because it involves passing values into classes
and functions.

Here's the problem .. I need to pass a PHP variable like $number into the
header of a PDF.
I have extended the FPDF class as follows....

class PDF extends FPDF{
function Header(){
$this->SetFont('Arial','BU',12);
$this->Cell(0,5,'User notes for invoice number '.$number,0,'1','L');
}
}


I hate it when I ask a question prematurely, because I could have figured it
out myself. Getter and Setter functions are the answer.

function setNumber($number){
$this->number = $number;
}

$pdf->setNumber('12345');