ID:          35513
 Updated by:  [EMAIL PROTECTED]
 Reported By: david at tulloh dot id dot au
-Status:      Open
+Status:      Bogus
 Bug Type:    Feature/Change Request
 PHP Version: 6CVS-2005-12-02 (CVS)
 New Comment:

Use {}.
var_dump($ob->{$field}[0]); // bar
var_dump($ob->{$field[0]}); // array(0=>"b")



Previous Comments:
------------------------------------------------------------------------

[2005-12-02 08:28:20] david at tulloh dot id dot au

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 this bug report at http://bugs.php.net/?id=35513&edit=1

Reply via email to