note 32286 deleted from language.types.object by googleguy

From: Date: Sat, 19 Jan 2013 03:42:38 +0000
Subject: note 32286 deleted from language.types.object by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193226@lists.php.net to get a copy of this message
Note Submitter: php at electricsurfer dot com ---- Here's an example on operator precedence between -> and [] & what happens with $object->$member[$array_element] <? class c { var $a = array('a'=>'aa','b'=>'ab'); var $b = 'c'; function show() { echo $this->a['a']; // -> 1st echo $this->a['b']; // outputs 'ab' $a = 'a'; $b = 'b'; echo $this->$a[$a]; // [] 1st, not what I expected echo $this->$a[$b]; // does NOT output 'ab' $this_a =& $this->$a; // work-around echo $this_a[$a]; // no question echo $this_a[$b]; $a_arr = array('a'=>'b'); echo $this->$a_arr[$a]; // [] 1st => outputs 'c' } } $c = new c(); $c->show(); ?>

« previous php.notes (#193226) next »