ID: 29562 User updated by: darcy at 1000camels dot com Reported By: darcy at 1000camels dot com Status: Open Bug Type: Scripting Engine problem Operating System: Linux, MacOSX PHP Version: 4.3.8 New Comment:
i got around this problem by globally defining all the variables which are to be used with a global scope. so, just before the include statement, setup your global $variable1, $variable2. this seems to work fine in my case - i was working with phpBB2, which i was trying to try into a CMS i'm working on. It worked fine for phpBB2. i suspect that other code might have trouble with this kind of fix. Previous Comments: ------------------------------------------------------------------------ [2004-09-07 13:54:07] mxou at mycosmos dot gr I've also encountered the same bug and was searching if someone had encountered it so far. Not only my own global variables are of no scope, PHP's superglobal structures become out of scope, also. Very irritating. ------------------------------------------------------------------------ [2004-08-11 06:22:07] darcy at 1000camels dot com does anyone have any more information on this? i'm finding it quite difficult to work around this problem. i've tried making an absolute call with the include (ie. using http://), but that's just causing more trouble. i can't get access to the cookies from within an absolute call... And the fix i described above doesn't really help, since i'm trying to source a rather large piece of code (phpBB2), which has lots of globals. too many to keep track of. besides, i don't think it's the best approach... ------------------------------------------------------------------------ [2004-08-10 09:57:30] cstdenis at on-track dot ca Looks like this is happening with PHP5 (release) too. ------------------------------------------------------------------------ [2004-08-09 19:05:59] darcy at 1000camels dot com i did some more experiments and have found a kind of fix. It would appear that if i globalize any of the variables which are losing scope inside of the function which sources the code, the variables keeps scope. this is interesting and may help me do what i need to do, but i still think this is a problem. if you want to see an example of my fix, look for the files called -fixed on my server: http://1000camels.com/phpBug/ ------------------------------------------------------------------------ [2004-08-09 10:46:55] boris at hident dot co dot il Happens to me too. 4.3.6 and 4.3.7 was fine. 4.3.8 and the 4.3.9-dev snapshots have the bug. Tried it both in Linux (Red-Hat and Fedora Core 2) and on Windows XP (Apache/1.3.31 (Win32)). I export some cookie variable to global scope $somevar = $_COOKIE['somevar']; in an included file. The $somevar variable is always empty inside included files from other fucntions, even though they are defined as global. register_globals is off. Hope this will get fixed ASAP, because restructuring my whole php application is not an option now. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/29562 -- Edit this bug report at http://bugs.php.net/?id=29562&edit=1