note 101929 added to language.oop5
| From: | dances_with_peons at live dot com | Date: | Tue, 18 Jan 2011 22:36:20 +0000 |
| Subject: | note 101929 added to language.oop5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175875@lists.php.net to get a copy of this message | ||
As of PHP 5.3, $className::funcName() works fine.
<?php
class test
{
public static function run() { print "Works\n"; }
}
$className = 'test';
$className::run();
?>
on my system, prints "Works". May work with earlier versions of PHP as well. Even if it
doesn't, there's always
<?php
$className = 'test';
call_user_func(array($className, 'run'));
?>
The point is, there's no need for eval.
----
Server IP: 69.147.83.197
Probable Submitter: 173.15.197.30
----
Manual Page -- http://www.php.net/manual/en/language.oop5.php
Edit -- https://master.php.net/note/edit/101929
Del: integrated -- https://master.php.net/note/delete/101929/integrated
Del: useless -- https://master.php.net/note/delete/101929/useless
Del: bad code -- https://master.php.net/note/delete/101929/bad+code
Del: spam -- https://master.php.net/note/delete/101929/spam
Del: non-english -- https://master.php.net/note/delete/101929/non-english
Del: in docs -- https://master.php.net/note/delete/101929/in+docs
Del: other reasons-- https://master.php.net/note/delete/101929
Reject -- https://master.php.net/note/reject/101929
Search -- https://master.php.net/manage/user-notes.php