Re: include file to global scope
| From: | Oliver Grätz | Date: | Fri, 14 Oct 2005 15:19:18 +0000 |
| Subject: | Re: include file to global scope | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224135@lists.php.net to get a copy of this message | ||
Claudio schrieb:
> I'm using PHP 5. I have a class operation that includes php files.
> Is there a way to include this files to global scope? So that difined vars
> and functions are global accesseble?
I know this problem from my early PHP days. If your problem is that you
want to include some class or function libraries then the simple
solution is: Do not include inside the function or class but let the
class or function just return the path name!
So instead of
function include_lib($name)
{
$path='functions/'.$name.'.php'; // or more werid stuff
include($path);
}
include_lib('test');
do
function lib_path($name)
{
$path='functions/'.$name.'.php'; // or more werid stuff
return $path;
}
include(lib_path('test'));
Perhaps your problem is exactly of this type or similar.
AllOLLi
____________
Inara: "It sounds like the sort of thing this crew can handle. I can't
guarantee they'll handle it particularly well, but..."
Nandi: "If they got guns, and brains at all..."
Inara: "They've got guns."
[firefly 113]