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 include (or require ) statement takes all the text/code/markup that exists in the specified file and copies it into the file that uses the include statement. Including files is very useful when you want to include the same PHP, HTML, or text on multiple pages of a website.
The __DIR__ can be used to obtain the current code working directory. It has been introduced in PHP beginning from version 5.3. It is similar to using dirname(__FILE__). Usually, it is used to include other files that is present in an included file.
dirname(__FILE__) allows you to get an absolute path (and thus avoid an include path search) without relying on the working directory being the directory in which bootstrap. php resides. (Note: since PHP 5.3, you can use __DIR__ in place of dirname(__FILE__) .)
Starting with “/” returns to the root directory and starts there. Starting with “../” moves one directory backwards and starts there. Starting with “../../” moves two directories backwards and starts there (and so on…) To move forward, just start with the first subdirectory and keep moving forward.
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With