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.

 

 

 

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