是否可以在PHP中声明一个静态和非静态的方法?
是否可以将对象中的方法声明为静态方法和非静态方法,该方法的名称与调用静态方法的名称相同?
我想创建一个具有静态方法“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();
可能吗?