Re: Requiring stuff question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert wrote:
I have the following in a config file:

// Define and require the Smarty library
define('SMARTY_DIR', 'Smarty/');
require(SMARTY_DIR . 'Smarty.class.php');

// Define the pager stuff
define('PAGER_DIR', 'Pager/');
require(PAGER_DIR . 'Pager.php');
require(PAGER_DIR . 'Pager_Wrapper.php');

// Define the DB package
define('PEAR_DB', 'DB/');
require(PEAR_DB . 'DB.php');

The Smarty stuff works no problem. The DB and Pager stuff do not. Since I am new to PHP I may be just misunderstanding how to do it.

indeed you are - your require statements are ok but some of the files (with relative paths) are not found because your include_path does not include the base directory where your PEAR classes are found (I guess that the DB and Pager classes are PEAR things :-)

either make sure include_path is set correctly, this can be done
in the php.ini, in a .htacess file (Apache specific) or by using:

// you have to decide what the value of $incPath should be!
ini_set('include_path', $incPath);

or you can change the define() statements in your config file
so that they define the full path to the directories in question rather than
a relative path e.g:

define('PAGER_DIR', 'C:/Path/To/PEAR/Base/Dir/Pager/');
require(PAGER_DIR . 'Pager.php');
require(PAGER_DIR . 'Pager_Wrapper.php');

.... I recommend reading up on include_path:

http://nl2.php.net/manual-lookup.php?pattern=INCLUDE_PATH&lang=en
http://nl2.php.net/manual/en/ini.core.php#ini.include-path

have fun.


I am using Apache/PHP on Windows.

Robert


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux