2
다음 코드를 사용하면 $ this-> myStaticFunc();를 호출 할 때 pro와 con를 찾고 있습니다. vs self :: myStaticFunc(); $this->myStaticFunction()
를 사용PHP 정적 함수 호출
class MyClass
private function myPrivateFunc() {
...
$this->myStaticFunc(); // or self::myStaticFunc();
...
}
// no need to tell me that i can't use $this in here
public static function myStaticFunc() { ... }
}
// access static function
MyClass::myStaticFunc();
제로 정보를 제공하고 검정색 또는 파란색 차를 구입해야하는지 알고 싶습니다 ... – hek2mgl
그들은 완전히 다른 목적으로 사용됩니다. ... 함수가 인스턴스에 대해 작동해야하는 경우이를 인스턴스 함수; 그렇지 않다면 정적 함수를 사용할 수 있습니다. –