From: david at tulloh dot id dot au
Operating system:
PHP version: 6CVS-2005-12-02 (CVS)
PHP Bug Type: Feature/Change Request
Bug description: A method of grouping variables so that the order of operators
can be made clear
Description:
------------
When using objects it can become very ambiguous what is occuring once you
start using variable variable names. The reproduce code shows a
non-useful example of where this might occur.
A concise example of the problem:
$ob->field[0] ==> array[0] ==> item
$ob->$field[0] ==> $ob->'b' ==> array
Being able to use brackets or something similar to force the -> operator
to act before the [] would allow for a choice of functionality in the
second example and provide the ability to make the code clearer.
$ob->($field[0])
($ob->$field)[0]
Both of these examples are currently not possible, a syntax error,
unexpected ( or [ occurs.
Reproduce code:
---------------
<?php
class Arrayise {
function __get($name) {
return array($name);
}
}
$ob = new Arrayise;
$field = 'bar';
var_dump($ob->$field[0]); // b
var_dump($ob->field[0]); // bar
?>
--
Edit bug report at http://bugs.php.net/?id=35513&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=35513&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=35513&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=35513&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35513&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=35513&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35513&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35513&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35513&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35513&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35513&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=35513&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=35513&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35513&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35513&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35513&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35513&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35513&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35513&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35513&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35513&r=mysqlcfg