Date: 10/28/00
- Next message: jccann <email protected>: "[PHP-DEV] PHP 4.0 Bug #7014 Updated: ibase_query (rest of php_interbase.dll?)"
- Previous message: Jonathan Sharp - Flyerware.com: "[PHP-DEV] CLibPDF Support"
- In reply to: waldschrott <email protected>: "[PHP-DEV] PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes"
- Next in thread: André Langhorst: "Re: [PHP-DEV] PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes"
- Reply: André Langhorst: "Re: [PHP-DEV] PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I think where Mike was mistaken was that he presumed that the new operator
would return a reference to the newly created object rather then a value.
Which is the source of another question and the topic of a number of bug
reports lately.
#7511
#7482
#7455
#7454
The problem is that it is not possible for the new operator to return a
reference. The ability, I believe, needs to be there. The question is
should it return a reference by default or only when explicitly requested.
//example by default
$joe = new foo(); //$joe will be populated with a reference to the
instantiated foo class;
//explicit example
$joe =& new foo(); //$joe requests a reference to the new object.
Either one would work fine. But the decision just needs to be made as to
which way to implement it.
Thanks for you help,
youngm
-----Original Message-----
From: waldschrott <email protected> [mailto:waldschrott <email protected>]
Sent: Saturday, October 28, 2000 7:17 AM
To: php-dev <email protected>
Subject: [PHP-DEV] PHP 4.0 Bug #7511 Updated: References are not
properly reassigned with classes
ID: 7511
Updated by: waldschrott
Reported By: heathm <email protected>
Status: Closed
Bug Type: Class/Object related
Assigned To:
Comments:
no bug here, here´s what you did...
1) created instance of foo on uninitialized $bar
2) created a reference in array $list to $bar
(read the chapter "references explained in the manual" if
you don´t understand the following)
3) created instance of foo on $bar and it´s referenced array
element
4) created another reference in array $list to $bar
finally there are 3 structures beeing the same, $bar, array
element 1, array element 2
Previous Comments:
---------------------------------------------------------------------------
[2000-10-28 08:13:21] heathm <email protected>
I found a rather strange problem with reference to objects. Take the
following:
<?php
class foo {
var $Name;
function foo($name) {
$this->Name = $name;
}
}
$bar = new foo('Mike');
$list[] =& $bar;
//unset($bar);
$bar = new foo('Jeremy');
$list[] =& $bar;
while(list($key, $val) = each($list))
echo "<br>$key = $val->Name";
?>
When going through the loop and echoing the Name parameter the both return
Jeremy. If I unset $bar first (by uncommenting it) it works fine. I'm not
exactly sure what's going on but it is rather strange.
Mike
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7511
-- 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>-- 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: jccann <email protected>: "[PHP-DEV] PHP 4.0 Bug #7014 Updated: ibase_query (rest of php_interbase.dll?)"
- Previous message: Jonathan Sharp - Flyerware.com: "[PHP-DEV] CLibPDF Support"
- In reply to: waldschrott <email protected>: "[PHP-DEV] PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes"
- Next in thread: André Langhorst: "Re: [PHP-DEV] PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes"
- Reply: André Langhorst: "Re: [PHP-DEV] PHP 4.0 Bug #7511 Updated: References are not properly reassigned with classes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

