如何在php中的子文件夹中引用库

I have the line $pdf = new FPDF(); which works if the FPDF library is in the root directory, but how do I use it if the library is in a sub folder. I have tried

$pdf = new mySubfolder/FPDF();

but it doesnt work. Any help please?

Try this, only include with directory structure.

require_once("mySubfolder/fpdf.php");
$pdf = new FPDF();

You could use namespaces (PHP 5 >= 5.3.0, PHP 7)

<?php
   namespace myMainFolder;

   use mySubFolder\PDF;

   $pdf = new PDF();

   var_dump($pdf);
?>