Re: Requiring stuff question

From: Date: Mon, 23 May 2005 15:15:29 +0000
Subject: Re: Requiring stuff question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-215748@lists.php.net to get a copy of this message
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


« previous php.general (#215748) next »