Custom PHP: Include External PHP Libraries
Arclab® Web Form Builder
Adjusting the Path of the PHP include File when including External PHP Libraries
External PHP libraries are usually included via "require_once".
Sample:
require_once('include-file.php');
If you want to integrate the TCPDF or FPDF library, we have already expanded the example code so that an error message is output if the path is incorrect.
Sample TCPDF:
$tcpdfinclude = 'tcpdf/tcpdf.php';
if(!stream_resolve_include_path($tcpdfinclude))ErrorCancel('Invalid
TCPDF include path');
require_once($tcpdfinclude);
Sample FPDF:
$fpdfinclude = 'fpdf/fpdf.php';
if(!stream_resolve_include_path($fpdfinclude))ErrorCancel('Invalid
FPDF include path');
require_once($fpdfinclude);
So to change the path you just need to change the variable $tcpdfinclude
or $fpdfinclude.
Please note the apostrophes ',
which enclose the path!
error_outline It is important to understand that the path of the PHP include file should be specified relative to the form file.
- First, locate the form file on your website, webform.php in this example.
- Then, starting with the form file, change to the directory that contains the include file of the PHP library.
- Anytime you need to go back a folder, add "../" to the path.
- If you want to move up a folder, use "foldername/"
- It can happen that the folder of the include file appears twice, e.g. tcpdf/tcpdf/tcpdf.php
- Please note that the path is case-sensitive depending
on the file system.
Sample: tcpdf/tcpdf.php is not the same as TCPDF/tcpdf.php
Samples:
The following examples assume the form file name is webform.php and you want
to include the PHP library TCPDF.
This works in the same way for FPDF or
other libraries, you just have to change the name of the include file.
1.
The form is in the folder: www.yourdomain.tld/forms/webform.php
and the PHP library is in the folder: www.yourdomain.tld/forms/tcpdf/tcppf.php
Path: tcpdf/tcpdf.php
2.
The form is in the folder: www.yourdomain.tld/forms/webform.php
and the PHP library is in the folder: www.yourdomain.tld/forms/tcpdf/tcpdf/tcppf.php
Path: tcpdf/tcpdf/tcpdf.php
3.
The form is in the root folder: www.yourdomain.tld/webform.php
and the PHP library is in the folder: www.yourdomain.tld/tcpdf/tcppf.php
Path: tcpdf/tcpdf.php
4.
The form is in the folder: www.yourdomain.tld/folder/webform.php
and the PHP library is in the folder: www.yourdomain.tld/tcpdf/tcppf.php
Path: ../tcpdf/tcpdf.php
5.
The form is in the folder: www.yourdomain.tld/folder/webform.php
and the PHP library is in the folder: www.yourdomain.tld/includes/tcpdf/tcppf.php
Path: ../includes/tcpdf/tcpdf.php
6.
The form is in the folder: www.yourdomain.tld/folder1/folder2/webform.php
and the PHP library is in the folder: www.yourdomain.tld/includes/tcpdf/tcppf.php
Path: ../../includes/tcpdf/tcpdf.php