note 28668 deleted from function.require by sniper
| From: | sniper@php.net | Date: | Tue, 04 Nov 2003 00:44:19 +0000 |
| Subject: | note 28668 deleted from function.require by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59811@lists.php.net to get a copy of this message | ||
Note Submitter: Satisfied PHP User
----
Subject: Require/Include via function calls
I tried to create a "smart" include function on my own such as follows:
function api_load($handle) {
require 'mySpecialAPIPath/'.$handle.'.php';
}
This was suppose to let me just:
api_load('bbs');
api_load('html');
BUT THIS WILL NOT WORK.
The require function is used inside a function call. In other words, all the content of the required
file is put INSIDE the api_load() function, not OUTSIDE as a regular require call would. This causes
problems with name spaces.
I settled for the following:
function objApi($handle) {
return 'obj/api/'.$handle.'.php';
}
include objApi('html');
include objApi('whois');
Maybe someone has something better.
peace.