note 28981 deleted from function.require by sniper

From: Date: Mon, 03 Feb 2003 14:55:03 +0000
Subject: note 28981 deleted from function.require by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-43329@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.

« previous php.notes (#43329) next »