Re: Function variables in classes
| From: | Nathan Nobbe | Date: | Thu, 01 Nov 2007 16:59:58 +0000 |
| Subject: | Re: Function variables in classes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263936@lists.php.net to get a copy of this message | ||
On 11/1/07, Eric Butera <eric.butera@gmail.com> wrote:
>
> I don't know if this has been said yet, but in 5.3 they added this:
> Dynamic static calls: $c = "classname"; $c::someMetod();
apparently it works in 5.2.4 as well:
<?php
class Foo {
static public function staticMethod() {
echo __METHOD__ . PHP_EOL;
}
public function nonStaticMethod() {
echo __METHOD__ . PHP_EOL;
}
}
$fooStr = 'Foo';
$fooStr::staticMethod();
Foo::staticMethod();
Foo::nonstaticMethod();
$foo = new Foo();
$foo->staticMethod();
$foo->nonstaticMethod();
?>
-nathan