php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38069 Unexpected behavior as a result of __get and __set
Submitted: 2006-07-11 17:20 UTC Modified: 2006-07-12 13:11 UTC
From: cslush at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.4 OS: Linux Kernel 2.6.15
Private report: No CVE-ID: None
 [2006-07-11 17:20 UTC] cslush at gmail dot com
Description:
------------
I am getting unexpected behavior from the __get and __set methods. I am assigning an array via __set and then, by accessing it with __get, I am unable to correctly pull the last key of the array.

end($this->array);
$last_key = key($this->array);

Reproduce code:
---------------
http://rafb.net/paste/results/z7GNVF49.html

Expected result:
----------------
123456789Last

Actual result:
--------------
Last123456789

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-12 10:43 UTC] tony2001@php.net
This is what latest CVS says on your code:
Fatal error: Cannot use array returned from C::__get('array') in write context
and this is expected.
 [2006-07-12 13:11 UTC] cslush at gmail dot com
How is this bogus and how are you getting a fatal error? I run this code on linux and it works 100%, with the exact unexpected behavior that I mentioned originally. Am I missing something?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 22:01:33 2024 UTC