Hello,
There is no such variable. However, this information can be retrieved from the generated PDF file using third party tools. For example if you are on Linux, you can use the following:
$num_pages = exec("pdftk ".$pdf_path." dump_data | grep NumberOfPages: | cut -d ' ' -f 2");