Date: 11/11/00
- Next message: Zeev Suraski: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Previous message: Rasmus Lerdorf: "Re: [PHP-DEV] fatal: libttf.so.2: open failed:"
- In reply to: Mike Heath: "[PHP-DEV] RE: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Next in thread: Zeev Suraski: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Reply: Zeev Suraski: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Reply: André Langhorst: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
As I understand it, altering $GLOBALS directly is *UNSUPPORTED* -- Don't do
it. Use global and an assignment. Don't dink around with an internal
structure ($GLOBALS) to do something where there is instead a documented
solution.
I believe Rasmus or Zeev even said this on the PHP General list, way back
when.
----- Original Message -----
From: Mike Heath <heathm <email protected>>
To: Kirill Maximov <kir <email protected>>
Cc: Andi Gutmans <andi <email protected>>; PHP Development <php-dev <email protected>>;
<php-qa <email protected>>; <danjrod <email protected>>
Sent: Friday, November 10, 2000 7:09 PM
Subject: RE: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch
> Kirill and others,
>
> > Hmm. I thought that
> >
> > $GLOBALS['a'] = new A;
> >
> > is absolute equivalent to
> >
> > global $a;
> > $a = new A;
> >
> > I don't care in this example what is returned by operator 'new'.
> > I suppose, that $a in second case should be absolutely equivalent to
> > GLOBALS['a'] regardsless right part of '=' sign.
>
> I though that too but apparantly what happens is $a is created inside the
> context of the function and points to the data of the real global $a so if
> you do something like $a = &$foo inside the function the real $a's
reference
> won't change. This should probably be documented better since saying
> something "PHP doesn't support C like pointers" doesn't quite cut it. It
> took me quite some time (and a number of bug postings) to figure this out.
>
>
> > Anyway, I don't understand why Andi's patch can work in both cases.
> > OK, 'new' returns reference. But $a should be === $GLOBALS['a'], IMO.
> > Or I've missed something?
>
> Explained above why not. I fully agree that as that is what is expected
but
> after looking under the hood of PHP a bit I can see why it isn't. Of
course
> if I had it my way I'd just get rid of the whole global $foo thing all
> together. :)
>
> > 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.
>
> (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.)
>
> Regards,
>
> Mike
>
>
> --
> PHP Quality Assurance Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-qa-unsubscribe <email protected>
> For additional commands, e-mail: php-qa-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
>
>
-- 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: Zeev Suraski: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Previous message: Rasmus Lerdorf: "Re: [PHP-DEV] fatal: libttf.so.2: open failed:"
- In reply to: Mike Heath: "[PHP-DEV] RE: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Next in thread: Zeev Suraski: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Reply: Zeev Suraski: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Reply: André Langhorst: "Re: [PHP-DEV] Re: [PHP-QA] RE: [PHP-DEV] Re: [PHP-QA] $obj = new foo() patch"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

