You are here: Re: [PHP] Requiring stuff question « PHP « IT news, forums, messages
Re: [PHP] Requiring stuff question

Posted by Jochem Maas on 05/23/05 18:15

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
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация