On 11/06/12 20:28, Richard Lynch wrote:
On Mon, June 11, 2012 2:13 pm, Stas Malyshev wrote:
And then one would expect some rather complex logic to compute -N
for
$var[-N]
I don't see much of complex logic here, but $a[2] = 'a' would create a
new array element if it does not exist, while $a[-2] can't. Not a big
issue, but somewhat inconsistent I guess.
$n = some_incredibly_long_and_complex_computation();
//and, for real fun, sometimes it returns positive, and sometimes
negative.
$s = $var[$n];
If $n is a negative value, an E_NOTICE will be triggered. To not do
if ($n< 0){
//whatever
}
else{
//something entirely different
}
Prior to your string offset can be looked at being bad practice.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php