note 99105 added to class.arrayaccess
| From: | uramihsayibok at osu1 dot php dot net | Date: | Wed, 28 Jul 2010 07:53:57 +0000 |
| Subject: | note 99105 added to class.arrayaccess | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171179@lists.php.net to get a copy of this message | ||
Actually, max at flashdroid, that code doesn't demonstrate returning references. While get()
may return by-ref, offsetGet() does not so you don't get a reference.
If you wanted a reference you'd have to use
<?php
public function &offsetGet($offset) {
return $this->get($offset);
}
?>
but that raises the "declaration of X must be compatible with Y" fatal error. So no, you
still cannot return references via ArrayAccess.
(The code "works" because <?php $obj['name'] = "boo"; ?>
triggers offsetSet, not offsetGet.)
----
Server IP: 64.71.164.2
Probable Submitter: 75.172.97.118
----
Manual Page -- http://www.php.net/manual/en/class.arrayaccess.php
Edit -- https://master.php.net/note/edit/99105
Del: integrated -- https://master.php.net/note/delete/99105/integrated
Del: useless -- https://master.php.net/note/delete/99105/useless
Del: bad code -- https://master.php.net/note/delete/99105/bad+code
Del: spam -- https://master.php.net/note/delete/99105/spam
Del: non-english -- https://master.php.net/note/delete/99105/non-english
Del: in docs -- https://master.php.net/note/delete/99105/in+docs
Del: other reasons-- https://master.php.net/note/delete/99105
Reject -- https://master.php.net/note/reject/99105
Search -- https://master.php.net/manage/user-notes.php