What is the significance of AliasNbPages in FPDF and how can it be used effectively?

AliasNbPages in FPDF is a method used to automatically insert the total number of pages in a PDF document. This can be useful for creating professional-looking documents with page numbering. To use AliasNbPages effectively, you can call it before the output of each page to ensure that the total number of pages is updated correctly.

<?php
require('fpdf.php');

class PDF extends FPDF
{
    function Header()
    {
        $this->AliasNbPages();
        $this->SetFont('Arial','B',12);
        $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    }
}

$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',12);
for($i=1;$i<=50;$i++)
    $pdf->Cell(0,10,'Printing line number '.$i,0,1);
$pdf->Output();
?>