How-to include PHP class files?

2011/09/16

Hi,
I’m trying to use your PHP classes but have problems to include the different files.
For example I want to create an photo upload application, I need to include the upload class files and what about the database?

Do you have any advice? Seems like including files is not so easy ;)

Thanks in advance
Peter

3 comments to “How-to include PHP class files?”

  1. admin says:

    Yeah PHP includes are not easy in the beginning :)

    The best way is to have one file in your website’s root (where your index.php file is located), call it config.php or db.php. Insert the the follwing code which defines your document root in PHP scripts:

    define(“DOC_ROOT”, dirname(__FILE__));

    Include that file in all your scripts.

    If you like to use our upload class you need to include this file first and than include the other files. I hope that will help.

  2. Peter says:

    Thanks for the help I tried what you suggested and yes it works. My includes are like these one:

    include_once '../db.php'; // I created here the DOC_ROOT variable
    include_once DOC_ROOT.'/libs/upload/php_upload_class.php';
    include_once DOC_ROOT.'/libs/upload/php_photo_upload_ext.php';