I have a php file that I use to print pdf (using FPDF). In this file I have a variable $date and I would like to show this variable $date in the header on each of the pages of my pdf document. That is my variable $date:
$convert_date=st开发者_运维知识库rtotime($selected_date);
global $date;
$date=date("d/m/Y",$convert_date);
And this is the class FPDF:
class PDF extends FPDF{
function setDate($dat){
$this->header_date = $dat;
}
function getDate(){
return $this->header_date;
}
function Header(){
$this->SetFont('Arial','B',16);
$this->setDate($date);
$this->Write (10, ' Date: '); //1° Write
$this->Write (10, $this->getDate()); //2° Write NOT WORKING
$this->Ln();
} ...
The problem is that the second $this->Write prints nothing.
I checked that if I call $this->setDate('abcd');, it prints "abcd" ok.
How can I pass this $date variable in my pdf header function?
I'm not sure because I've not used them in about five years, but don't you have to declare $date as being a global inside the Header()
function?
function Header() {
$date = $GLOBALS['date'];
...
精彩评论