note 69144 deleted from language.references.whatdo by bjori
| From: | bjori@php.net | Date: | Thu, 24 Aug 2006 19:26:56 +0000 |
| Subject: | note 69144 deleted from language.references.whatdo by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-116278@lists.php.net to get a copy of this message | ||
Note Submitter: randallgirard at hotmail dot com
Reason: in docs
----
After countless hours of debugging, headaches, and research... It finally hit me what was wrong with
a class I was writing.
Take the following code for example:
class foo {
function foo() {
$bar = new bar();
$this->bar =& $bar; # Reference
}
}
class bar { }
$foobar = new foo();
I soon realised, that objects which I created in the first routine were being copied... As what
I'm designing has an Object Tree structure, and variables were missing later at runtime.
Anywho, perhaps I was missing a reference somewhere or something but all the code looked correct!!
Then rereading the References documentation on php.net, I realised that php4's 'new'
routine does not pass as reference, yet php5 does and it is deprecated hence it prints an E_STRICT
error. I havn't used php5 myself yet, but wow how irritating... It should have passed by
reference long ago, or well documented that creating objects should be done with references.
I still and will always say, Perl is and will always be much > PHP