I use the FPDF Class in PHP to create PDFs. All works well, but now I need the PDF with different logos in the header.
Creating a header works well.
class PDF extends FPDF {
function Footer() {
// some code
}
function Header() {
$this->Image('PDF/images/pdf_header.png', 0, 0, 215);
}
}
Now I need something like this. The variable "$is_summer" exists in my file.
class PDF extends FPDF {
function Footer() {
// some code
}
function Header() {
if ($is_summer)
$this->Image('PDF/images/pdf_header_summer.png', 0, 0, 215);
} else {
$this->Image('PDF/images/pdf_header_winter.png', 0, 0, 215);
}
}
}
But I get: Notice: Undefined variable: is_summer in createPDFpriv.php on line 200.
Ok, undefined var. So I tried
function Header($is_summer) {
if ($is_summer)
$this->Image('PDF/images/pdf_header_summer.png', 0, 0, 215);
} else {
$this->Image('PDF/images/pdf_header_winter.png', 0, 0, 215);
}
}
Another error: Warning: Declaration of PDF::Header($is_summer) should be compatible with FPDF::Header() in createPDFpriv.php on line 145
Also tried:
if ($is_summer) {
function Header() {
$this->Image('PDF/images/pdf_header_summer.png', 0, 0, 215);
}
} else {
function Header() {
$this->Image('PDF/images/pdf_header_winter.png', 0, 0, 215);
}
}
Also an error: parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in createPDFpriv.php on line 199. Ok, there is a function expected, this doesn't work.
Can anyone help?