nadeemshafi9 Posted April 2, 2008 Share Posted April 2, 2008 hi guys i work on a system in which i need to make a function that dynamicaly checks if a include file exists in the site specific folder otherwise use includes folder. function site_specific_include($path) { $file = basename($path); if(ereg($path, "../")) $dotslash = "../"; if(file_exists($dotslash."site_specific/".$file)) { include($dotslash."site_specific/".$file); } else { include($dotslash."includes/".$file); } } works fine but the problem is that objects instantiated outside the include file are no longer visible to the include file so i have to instantiate them inside now. i recon its a memory scope issue but how do i resolve it ? i used require require once include once i dont know ? it affects my styles.php include in the main file too Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/ Share on other sites More sharing options...
uniflare Posted April 2, 2008 Share Posted April 2, 2008 Its because you are including them inside a function. Use Global $var,$array['item'],$obj->variable,$etc; And make all the variables the includes need into globals. (OOP and Classes makes this MUCH easier) Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/#findComment-507395 Share on other sites More sharing options...
nadeemshafi9 Posted April 2, 2008 Author Share Posted April 2, 2008 have many includes and systems oop globalisation of eacj inner var and outser var vice versa interaction stuff is long things, need a more better solution thanks thogh Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/#findComment-507431 Share on other sites More sharing options...
nadeemshafi9 Posted April 2, 2008 Author Share Posted April 2, 2008 problem is i use oop php 4 so no public private stuff, tried a few methods cant find a simple solution all solutions are long, got to mujch code to cover so i cant use a long solution Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/#findComment-507510 Share on other sites More sharing options...
Daniel0 Posted April 2, 2008 Share Posted April 2, 2008 [...] i use oop php 4 [...] Upgrade. Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/#findComment-507513 Share on other sites More sharing options...
nadeemshafi9 Posted April 2, 2008 Author Share Posted April 2, 2008 [...] i use oop php 4 [...] Upgrade. Legacey systems my brother BIG MONEY Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/#findComment-507534 Share on other sites More sharing options...
Daniel0 Posted April 2, 2008 Share Posted April 2, 2008 Well, I find it immensely annoying when people don't upgrade. They're preventing progression. How long time did it take after the release of PHP5 before you could actually use it? All because of people who are not upgrading. Same goes for Internet Explorer. It's still necessary to support IE6 even though IE7 has been out for a long time - all because of people who are too lazy to upgrade. Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/#findComment-507539 Share on other sites More sharing options...
nadeemshafi9 Posted April 2, 2008 Author Share Posted April 2, 2008 i said the exact same thing before i styarted working id love to work withh php 5 but teh problem is that most legacey systems the ones which are the best because they do there job well so they have lasted longer live on php 4 some even 3 lol, but yeh i wish i had php 5 systems so i could do proper oop with protection etc and all those little extras but it aint happening. IE 7 is just a bunch of asses cos they removed the glitch so u cant determin it using ie 6 glitch so u have to use object creation detection they are trying to make it so u develop on there platform IE7 and 6 are great to use but they are crap to develop on and develop for. Firefox is crap to use but is great to develop on because it has many tools and it knows what ur trying to do.l Quote Link to comment https://forums.phpfreaks.com/topic/99176-includes-scope-problem/#findComment-507548 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.