ID: 29562 Comment by: cstdenis at on-track dot ca 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:
Looks like this is happening with PHP5 (release) too. Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2004-08-07 20:13:16] darcy at 1000camels dot com Description: ------------ This is a somewhat complicated bug to demonstrate. i have placed files online so that the behaviour can be demonstrated. Essentially, the bug is that when you include a php script using include() with a relative url (not absolute), global variables used within a function in the sourced code are not available. this seems to occur only when the original include() is within a class or function. if it is in open code, it works find. it's a complex bug and i'm not sure the best way to analyze. Reproduce code: --------------- http://1000camels.com/phpBug/ four files (and their source): test-open-code.php - works test-within-class.php - does not work test-within-function.php - does not work testMod.php - code which is being sourced Expected result: ---------------- i expect the global variable to be available Actual result: -------------- the global variable (in my example $anObject and $aVariable) are not available. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29562&edit=1