Reply to Re: include file to global scope

Your name:

Reply:


Posted by Oliver Grδtz on 10/14/05 18:19

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]

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация