简体   繁体   中英

Force to include file from same directory and not include_path

I am trying to use FPDF_Code39 class to print bar codes that extends the FPDF class. I am getting this error:

Warning (2): include(helveticab.php) [function.include]: failed to open stream: No such file or directory [D:\xampp\php\PEAR\fpdf.php, line 541]

The catch is in D:\\xampp\\php\\PEAR\\fpdf.php . It is including fpdf.php from the PEAR whereas I want it to include fpdf from the same directory as FPDF_Code39 class as I have the latest FPDF there.

I confirmed this issue by temporarily renaming PEAR/fpdf.php and everything works like a charm.

How do I force it to pick up FPDF from the same directory rather than include_path? Here is the require's that I have...

require('./fpdf.php'); \\I read at many places that this will do it.
require(dirname(__FILE__).'/fpdf.php');
require('fpdf.php')

Your help is really appreciated...

The second one is the most stable because it does not depend on the include path (like the third) nor on the current working directory (like the first).

Since PHP 5.3 you can also write

require __DIR__ . '/fpdf.php';

instead

require dirname(__FILE__).'/fpdf.php';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM