For FPDF, I am trying to either add PHP variables inside a background image, e.g.
//BACKGROUND
if (strpos($Result, '1') !== false) {
$Background = 'images/Cert-Sample-1.jpg';
}
$this->Image($Background,0,0,0,300);
or by putting the background setting inside the if statements
//BACKGROUND
if (strpos($Result, '1') !== false) {
$this->Image('images/Cert-Sample-1.jpg',0,0,0,300);
}
But neither seems to work. Both statements are totally disregarded and the background remains blank. However, if I place echo "YES";
inside each if statement instead, this works and outputs "YES" correctly as expected.
If I remove the if statement from around the 2nd option, it also works as expected and outputs the background image.
In both these options, they're inside a function. Can PHP variables not be used inside functions? This would explain why the first option doesn't work, but not the second.
class PDF extends FPDF
{
// Page header
function Header()
{
// LINES OF CODE ABOVE IS TO BE INSERTED HERE
$this->Image('images/pdf-header.png',5,5);
// END BACKGROUND
}
// Page footer
function Footer()
{
$this->SetY(-20);
//$this->Image('images/pdf-footer.jpg');
}
}
Any thoughts on how to get around this?