note 76540 added to language.oop5.static
| From: | phpman dot 10 dot dto at spamgourmet dot com | Date: | Thu, 19 Jul 2007 19:04:52 +0000 |
| Subject: | note 76540 added to language.oop5.static | ||
| Groups: | php.notes php.notes | ||
| Request: | Send a blank email to php-notes+get-128739@lists.php.net to get a copy of this message | ||
If you need to access a static class member dynamically:
<?php
class Foo {
public static $bar = 'yay';
}
function getstatic($name) {
return Foo::$$name; // syntax highlighting is funny, but this works
}
echo getstatic('bar'); // prints 'yay'
?>
----
Server IP: 64.71.164.2
Probable Submitter: 207.126.230.225
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- https://master.php.net/note/edit/76540
Del: integrated -- https://master.php.net/note/delete/76540/integrated
Del: useless -- https://master.php.net/note/delete/76540/useless
Del: bad code -- https://master.php.net/note/delete/76540/bad+code
Del: spam -- https://master.php.net/note/delete/76540/spam
Del: non-english -- https://master.php.net/note/delete/76540/non-english
Del: in docs -- https://master.php.net/note/delete/76540/in+docs
Del: other reasons-- https://master.php.net/note/delete/76540
Reject -- https://master.php.net/note/reject/76540
Search -- https://master.php.net/manage/user-notes.php