note 49691 added to language.oop

From: Date: Fri, 04 Feb 2005 21:56:05 +0000
Subject: note 49691 added to language.oop
Groups: php.notes 
Request: Send a blank email to php-notes+get-84545@lists.php.net to get a copy of this message
Didn't see this anywhere obvious, so I'm posting it here. To access a memeber of an array with another variable you use $arr[$name] To access a class method or property, you use $obj->{$name} You can also use the return value of a function. <?php class Test { function methodName(){ echo 'works!'; } } function getName(){ return 'methodName'; } $t = new Test(); $t->{getName()}(); //works! ?> ---- Manual Page -- http://www.php.net/manual/en/language.oop.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49691 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49691&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49691&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49691&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49691&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49691&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49691&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84545) next »