Re: [RFC]Call for voting about const array/string dereference

From: Date: Tue, 13 Dec 2011 13:15:49 +0000
Subject: Re: [RFC]Call for voting about const array/string dereference
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-56907@lists.php.net to get a copy of this message
> Call for voting about the const array/string derefernce RFC now. > > you can find more info here: > https://wiki.php.net/rfc/constdereference#vote I have always wondered why array dereference does not just work on arbitrary expressions in PHP like other operators do. Even with the latest modification that allows dereferencing function calls, this works: md5('')[0] but this results in a parse error (syntax error, unexpected '['): (md5(''))[0] Then there are expressions like ('a'.'b')[0], all sorts of combinations of operators... Why not just treat any 'expression[expression]' as an array dereference as other languages do? >> echo "foobar"["foo"][0]; > > "foobar"["foo"] - Why not "undefined index"? "foo" is converted to an integer, yielding zero. 'Undefined index' seems to make more sense to me but PHP 5.3 behaves the same way. -- Oleg

« previous php.internals (#56907) next »