From: myle34 at hotmail dot com
Operating system: Windows XP Home
PHP version: 5.0.0b2 (beta2)
PHP Bug Type: Variables related
Bug description: Global vs. class vs. variable scope w/ include

This is related to Bug #26173 ([url][/url]) but
the reproduce code was wrong.

I am using Windows XP Home and Apache 2.0.47 with PHP beta 2.

This bug is related to function/class/global scopes.

Note that if you merge foo.php and bar.php (foo.php and right after that
bar.php) (ie. without the include_once), this will work as expected!

I haven't tested this with include but I suspect it would have the same

Reproduce code:
// foo.php
class TestOne {
function __construct() { include_once 'bar.php'; }
$TestOne = new TestOne();

// bar.php
// uncommenting this makes it work
// global $foo;
$foo = 'bar';
// uncommenting this does nothing
// global $foo;
function TestTwo() {
global $foo; echo $foo;

Expected result:

Actual result:
No output

Edit bug report at [url][/url]
Try a CVS snapshot (php4): [url][/url]
Try a CVS snapshot (php5): [url][/url]
Fixed in CVS: [url][/url]
Fixed in release: [url][/url]
Need backtrace: [url][/url]
Try newer version: [url][/url]
Not developer issue: [url][/url]
Expected behavior: [url][/url]
Not enough info: [url][/url]
Submitted twice: [url][/url]
register_globals: [url][/url]
PHP 3 support discontinued: [url][/url]
Daylight Savings: [url][/url]
IIS Stability: [url][/url]
Install GNU Sed: [url][/url]
Floating point limitations: [url][/url]