docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: php-oop-access-modifiers
|
||||
title: "PHP OOP Access Modifiers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["public private protected", "PHP 접근 제어자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "oop", "access-modifiers"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_access_modifiers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Access Modifiers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`protected` occupies a middle ground invisible from direct outside access, YET fully usable inside a subclass via its own method — a child class can't do `$apple->name` directly, but a method it defines (like `getType()`) CAN read `$this->name` because it executes inside the class hierarchy, not from outside it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`public`** (default if unspecified) — accessible from anywhere. [S1]
|
||||
- **`protected`** — accessible within the class AND by derived (child) classes; NOT accessible directly from outside. [S1]
|
||||
- **`private`** — accessible ONLY within the exact class where defined; not even child classes can access it directly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Public (works from outside): `class Fruit { public $name; ... } $apple = new Fruit(); $apple->name = "Apple"; // OK`. [S1]
|
||||
- Private (fails from outside): `class Fruit { private $name; ... } $apple->name = "Apple"; // Error`. [S1]
|
||||
- Protected (fails from outside): `class Fruit { protected $name; ... } $apple->name = "Apple"; // Error`. [S1]
|
||||
- Protected accessible via a child class's own method: `class Fruit { protected $name; public function setType($name) { $this->name = $name; } } class Apple extends Fruit { public function getType() { echo "Name: " . $this->name . "."; } } $apple = new Apple(); $apple->setType("Apple"); echo $apple->getType(); // works — accessed via a method, not directly`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **protected의 이중적 접근성**: 외부에서 직접 접근($apple->name)은 불가하지만, 자식 클래스가 정의한 메서드 내부($this->name)에서는 접근 가능하다는 점이 예제로 명확히 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Fruit→Apple 상속 구조에서 protected 속성에 자식 클래스 메서드로 접근하는 것이 캡슐화의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Protected property accessible via a child class's method, not directly (PHP):
|
||||
```php
|
||||
class Fruit {
|
||||
protected $name;
|
||||
public function setType($name) { $this->name = $name; }
|
||||
}
|
||||
class Apple extends Fruit {
|
||||
public function getType() { echo "Name: " . $this->name . "."; }
|
||||
}
|
||||
$apple = new Apple();
|
||||
$apple->setType("Apple");
|
||||
echo $apple->getType(); // works
|
||||
// echo $apple->name; // Error: cannot access protected property directly
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Destructor]], [[PHP OOP Inheritance]]
|
||||
- **참조 맥락:** 접근 제어의 기초 — 상속(Inheritance) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Access Modifiers — https://www.w3schools.com/php/php_oop_access_modifiers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Access Modifiers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user