note 120707 added to language.namespaces.dynamic
| From: | m dot mannes at gmail dot com | Date: | Sat, 25 Feb 2017 18:36:56 +0000 |
| Subject: | note 120707 added to language.namespaces.dynamic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208854@lists.php.net to get a copy of this message | ||
Case you are trying call a static method that's the way to go:
<?php
class myClass
{
public static function myMethod()
{
return "You did it!\n";
}
}
$foo = "myClass";
$bar = "myMethod";
echo $foo::$bar(); // prints "You did it!";
?>
----
Server IP: 72.52.91.14
Probable Submitter: 179.155.223.154
----
Manual Page -- http://php.net/manual/en/language.namespaces.dynamic.php
Edit -- https://master.php.net/note/edit/120707
Del: integrated -- https://master.php.net/note/delete/120707/integrated
Del: useless -- https://master.php.net/note/delete/120707/useless
Del: bad code -- https://master.php.net/note/delete/120707/bad+code
Del: spam -- https://master.php.net/note/delete/120707/spam
Del: non-english -- https://master.php.net/note/delete/120707/non-english
Del: in docs -- https://master.php.net/note/delete/120707/in+docs
Del: other reasons-- https://master.php.net/note/delete/120707
Reject -- https://master.php.net/note/reject/120707
Search -- https://master.php.net/manage/user-notes.php