note 95692 added to language.references.whatdo
| From: | Amaroq at osu1 dot php dot net | Date: | Sat, 16 Jan 2010 11:14:05 +0000 |
| Subject: | note 95692 added to language.references.whatdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165022@lists.php.net to get a copy of this message | ||
I think a correction to my last post is in order.
When there is a constructor, the strange behavior mentioned in my last post doesn't occur. My
guess is that php was treating reftest() as a constructor (maybe because it was the first function?)
and running it upon instantiation.
<?php
class reftest
{
public $a = 1;
public $c = 1;
public function __construct()
{
return 0;
}
public function reftest()
{
$b =& $this->a;
$b++;
}
public function reftest2()
{
$d =& $this->c;
$d++;
}
}
$reference = new reftest();
$reference->reftest();
$reference->reftest2();
echo $reference->a; //Echoes 2.
echo $reference->c; //Echoes 2.
?>
----
Server IP: 69.147.83.197
Probable Submitter: 24.16.127.219
----
Manual Page -- http://www.php.net/manual/en/language.references.whatdo.php
Edit -- https://master.php.net/note/edit/95692
Del: integrated -- https://master.php.net/note/delete/95692/integrated
Del: useless -- https://master.php.net/note/delete/95692/useless
Del: bad code -- https://master.php.net/note/delete/95692/bad+code
Del: spam -- https://master.php.net/note/delete/95692/spam
Del: non-english -- https://master.php.net/note/delete/95692/non-english
Del: in docs -- https://master.php.net/note/delete/95692/in+docs
Del: other reasons-- https://master.php.net/note/delete/95692
Reject -- https://master.php.net/note/reject/95692
Search -- https://master.php.net/manage/user-notes.php