--- id: php-oop-static-properties title: "PHP OOP Static Properties" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["static properties", "PHP 정적 속성"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.89 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["php", "programming", "w3schools", "oop", "static"] raw_sources: ["https://www.w3schools.com/php/php_oop_static_properties.asp"] applied_in: [] github_commit: "" --- # [[PHP OOP Static Properties]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) A child class can read a parent's static property TWO different ways with different syntax for each β€” `x::$value` (via the child's OWN class name, since it inherited the static property) or `parent::$value` from inside a method β€” showing that static properties are inherited and directly accessible through the child's name, unlike static methods which more often route through `parent::`. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`static` property** β€” declared like `public static $prop = value;`; accessible without instantiating the class. [S1] - **Access via `ClassName::$prop`** β€” the standard external access syntax (uses `$` before the property name, unlike static methods). [S1] - **Access via `self::$prop`** β€” used inside a method of the same class. [S1] - **Access via `parent::$prop`** β€” used inside a child class's method to reach the parent's static property. [S1] - **Direct inherited access** β€” a static property is also directly reachable via the CHILD class name (`x::$value`) since it's inherited, without needing `parent::`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Direct static property access: `class pi { public static $value = 3.14159; } echo pi::$value;`. [S1] - Access via self inside a method: `class pi { public static $value=3.14159; public function staticValue() { return self::$value; } } $pi = new pi(); echo $pi->staticValue();`. [S1] - Child class access β€” both direct and via parent::: `class pi { public static $value=3.14159; } class x extends pi { public function xStatic() { return parent::$value; } } echo x::$value; // direct, works because inherited $x = new x(); echo $x->xStatic(); // via parent:: inside a method`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” μ›μ£Όμœ¨(pi)처럼 클래슀 전체가 κ³΅μœ ν•˜λŠ” μƒμˆ˜μ  값을 정적 μ†μ„±μœΌλ‘œ ν‘œν˜„ν•˜λŠ” 것이 λŒ€ν‘œ μ‹€μ „ 사둀닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Accessing an inherited static property directly via the child class name (PHP): ```php class pi { public static $value = 3.14159; } class x extends pi { public function xStatic() { return parent::$value; } } echo x::$value; // direct access via child class name (inherited) $x = new x(); echo $x->xStatic(); // access via parent:: inside a method ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.89 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP OOP Static Methods]], [[PHP Namespaces]] - **μ°Έμ‘° λ§₯락:** OOP μ„Ήμ…˜μ˜ λ§ˆμ§€λ§‰ β€” λ„€μž„μŠ€νŽ˜μ΄μŠ€(Namespaces) μ„Ήμ…˜μœΌλ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP OOP - Static Properties β€” https://www.w3schools.com/php/php_oop_static_properties.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Static Properties" page (Astra wiki-curation, P-Reinforce v3.1 format).