Files
2nd/10_Wiki/Dev/Topic_PHP/PHP_OOP_Static_Methods.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

4.2 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
php-oop-static-methods PHP OOP Static Methods Programming_Language draft conceptual
static keyword
parent::
PHP 정적 메서드
B 0.9 2026-07-04 2026-07-04
php
programming
w3schools
oop
static
https://www.w3schools.com/php/php_oop_static_methods.asp

PHP OOP Static Methods

🎯 한 줄 통찰 (One-line insight)

Calling a static method from a CHILD class requires the parent:: keyword instead of the class name, even though the static method literally belongs to a specific class — this differs from calling a static method from an unrelated class (which uses the explicit class name like A::welcome()), showing parent:: is reserved specifically for the inheritance relationship. [S1]

🧠 핵심 개념 (Core concepts)

  • static keyword — creates a method callable WITHOUT instantiating the class first. [S1]
  • Access via ClassName::method() — the standard way to call a static method from outside. [S1]
  • Access via self::method() — used to call a static method from a non-static method WITHIN the same class (e.g., inside a constructor). [S1]
  • Cross-class static calls — a static method must be public to be called from another class's method. [S1]
  • Access via parent::method() — used specifically when a child class wants to call a static method defined in its parent. [S1]

📖 세부 내용 (Details)

  • Direct static call: class greeting { public static function welcome() { echo "Hello World!"; } } greeting::welcome();. [S1]
  • Static call with arguments: class calc { public static function sum($x, $y) { return $x * $y; } } $res = calc::sum(6, 4);. [S1]
  • Static called via self from constructor: class greeting { public static function welcome() {...} public function __construct() { self::welcome(); } } new greeting();. [S1]
  • Static called from another class: class A { public static function welcome() {...} } class B { public function message() { A::welcome(); } }. [S1]
  • Static called via parent:: from a child class: class domain { protected static function getWebsiteName() { return "W3Schools.com"; } } class domainW3 extends domain { public $websiteName; public function __construct() { $this->websiteName = parent::getWebsiteName(); } }. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • 상속 관계에서의 특수 키워드: 자식 클래스에서 부모의 정적 메서드를 호출할 때는 클래스 이름이 아니라 parent:: 키워드를 사용해야 한다는 점이 강조됨. [S1]

🛠️ 적용 사례 (Applied in summary)

현재 발견된 실제 적용 사례가 없습니다 — 부모 클래스의 protected static 메서드를 자식 클래스 생성자에서 parent::로 호출하는 것이 실전 활용의 대표 사례다. [S1]

💻 코드 패턴 (Code patterns)

Calling a parent's static method from a child class (PHP):

class domain {
    protected static function getWebsiteName() {
        return "W3Schools.com";
    }
}
class domainW3 extends domain {
    public $websiteName;
    public function __construct() {
        $this->websiteName = parent::getWebsiteName();
    }
}

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.90
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Static Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).