最佳答案
对象中的方法是否可以同时声明为静态和非静态方法,其名称与调用静态方法的名称相同?
我想创建一个类,它有一个静态方法“ send”和一个调用静态函数的非静态方法。例如:
class test {
private $text;
public static function instance() {
return new test();
}
public function setText($text) {
$this->text = $text;
return $this;
}
public function send() {
self::send($this->text);
}
public static function send($text) {
// send something
}
}
我希望能够调用这两个函数
test::send("Hello World!");
还有
test::instance()->setText("Hello World")->send();
有可能吗?