Date: 11/11/00
- Next message: hholzgra <email protected>: "[PHP-DEV] PHP 4.0 Bug #7756 Updated: Problems w/include """
- Previous message: bens <email protected>: "[PHP-DEV] PHP 4.0 Bug #7756: Problems w/include """
- In reply to: Mike Heath: "[PHP-DEV] RE: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Next in thread: Daniel J. Rodriguez: "[PHP-DEV] Summary: $obj = new foo() patch"
- Reply: Daniel J. Rodriguez: "[PHP-DEV] Summary: $obj = new foo() patch"
- Reply: André Langhorst: "[PHP-DEV] big summary OO"
- Reply: Andi Gutmans: "[PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi again,
Mike Heath wrote:
> > If we want to force 'rich' OO design, let's wait until PHP 5.0. IMO,
> > a few peoply will upgrade to 4.0.4 if they'll have to rewrite their code
> > (possibly, a LOT of code).
> > But, I think, core team understands importance of compatibility issue.
> That's
> > why Andi reversed the patch for now, isn't it? ;-)
>
> Well I have to agree with you there. There are a lot of OO features I would
> love to see in PHP but I'm certainly not counting on them until future
> versions. The problem (regarding Andi's patch) is that the expected
> behavior of:
>
> <?php
> class foo {
> function foo($a) {
> global $ListOfObjects;
>
> $this->a = a;
> $ListOfObjects[] = &$this;
> }
>
> $bar = new foo()
> ?>
>
> would be that $ListOfObjects[0] and $bar referenced the same data. They do
> not. This is very frustrating to many people are there are 5 or more bugs
> in the bugs database pointing this out. I'm convinced this is a serious
> issue and needs to be fixed. I can only pray that *some* fix will get into
> PHP 4.0.4.
Well, the only solution I can imagine in this case is to change the way
how 'global' directive works.
As far as I've understood, for now, if I declare
variable as global, I just make it a reference to an element of $GLOBALS
array (something like this: $a = &$GLOBALS['a']). Or something similar.
So any code that assigns $a = &{something} will just change the local $a.
So, the following code prints 5, not 6.
function tt()
{
global $a;
$a = 5;
$b = 6;
$a = &$b;
}
tt();
echo $a;
I'm afraid, I suppose it to be a bug, though I've never used references
explicitly so far (most of my code is for PHP3). I think, 'global'
shouldn't be implemented as references to $GLOBALS.
And in this case, Andi's patch will work smoothly.
>
> (BTW -- regarding my explanation above concerning the difference between
> global $foo and $GLOBALS['foo']. This example will still work since I'm not
> changing the reference to $ListOfObjects just its array members.)
Its clear ;)
>
> Regards,
>
> Mike
With best regards,
KIR
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: hholzgra <email protected>: "[PHP-DEV] PHP 4.0 Bug #7756 Updated: Problems w/include """
- Previous message: bens <email protected>: "[PHP-DEV] PHP 4.0 Bug #7756: Problems w/include """
- In reply to: Mike Heath: "[PHP-DEV] RE: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Next in thread: Daniel J. Rodriguez: "[PHP-DEV] Summary: $obj = new foo() patch"
- Reply: Daniel J. Rodriguez: "[PHP-DEV] Summary: $obj = new foo() patch"
- Reply: André Langhorst: "[PHP-DEV] big summary OO"
- Reply: Andi Gutmans: "[PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

