Re: include file to global scope

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux