note 28981 added to function.require
| From: | brousky at rack1 dot php dot net | Date: | Wed, 29 Jan 2003 17:41:29 +0000 |
| Subject: | note 28981 added to function.require | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43082@lists.php.net to get a copy of this message | ||
Re: Satisfied PHP User 20-Jan-2003 06:07 :
-----
I settled for the following:
function objApi($handle) {
return 'obj/api/'.$handle.'.php';
}
include objApi('html');
include objApi('whois');
Maybe someone has something better.
-----
I suppose the goal of creating a function objApi() is to avoid having to bother with the path to
your files when including them. In this case, why don't you simply set a constant that has this
path and use it has follows :
define("OBJAPI_PATH","obj/api");
then when you include files :
include OBJAPI_PATH . 'html.php';
and if you really want to keep the ".php" out of your file inclusion, create another
define("OBJAPI_EXT",".php");
and include your files as follows :
include OBJAPI_PATH . 'html' . OBJAPI_EXT;
put the constant definitions in the same file as you declared the objApi() function and they should
be as available as this function is.
--
http://www.php.net/manual/en/function.require.php
http://master.php.net/manage/user-notes.php?action=edit+28981
http://master.php.net/manage/user-notes.php?action=delete+28981
http://master.php.net/manage/user-notes.php?action=reject+28981