Code
FPDF Problem Variable in Header or Footer Function Scoping Problem
Sometime you face scoping problem in FPDF. Example:
$party = $_POST['name'];
class PDF extends FPDF
{
function Header()
{
$this->Cell(150);
$this->Cell(30,10,$party,0,0,'C');
}
}
Here Party name not show because of scoping problem.
To solve this problem using GLOBAL variable.
Using GLOBAL you can use this variable anywhere any function.
Example Code:
$party = $_POST['name'];
class PDF extends FPDF
{
function Header()
{
global $party;
$this->Cell(150);
$this->Cell(30,10,$party,0,0,'C');
}
}
Hope to solve this problem. Stay with us. Happy Coding…