docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동

최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치.
콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서
전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한
업데이트0615/무제 3.canvas 뿐).
This commit is contained in:
Antigravity Agent
2026-07-05 00:44:01 +09:00
parent e9cbf23ab5
commit 9a135bd19d
6127 changed files with 0 additions and 0 deletions
@@ -0,0 +1,74 @@
---
id: php-match
title: "PHP Match"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["match expression", "PHP match"]
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", "match", "php8"]
raw_sources: ["https://www.w3schools.com/php/php_match.asp"]
applied_in: []
github_commit: ""
---
# [[PHP Match]]
## 🎯 한 줄 통찰 (One-line insight)
`match` (PHP 8.0+) uses STRICT comparison (`===`) internally while `switch` uses loose comparison (`==`) — this means `match` won't accidentally match a string `"1"` against an int `1` the way `switch` might, making `match` both safer and more predictable, on top of returning a value and auto-breaking after any match. [S1]
## 🧠 핵심 개념 (Core concepts)
- **`match`** (PHP 8.0+) — evaluates an expression against alternatives using strict (`===`) comparison, returns a value. [S1]
- **Four key differences from switch** — more readable syntax; returns a value (switch doesn't); auto-breaks after a match (switch needs explicit `break`); strict comparison (switch uses loose `==`). [S1]
- **Syntax** — `$result = match($expr) { cond1 => val1, cond2, cond3 => val2, default => defaultVal };`. [S1]
- **Multiple conditions per arm** — comma-separated conditions sharing one result. [S1]
- **`UnhandledMatchError`** — thrown if no condition matches AND there's no `default` arm. [S1]
## 📖 세부 내용 (Details)
- Basic match (equivalent to the switch example): `$favcolor = "red"; $text = match($favcolor) { "red" => "Your favorite color is red!", "blue" => "...", "green" => "...", default => "..." }; echo $text;`. [S1]
- Multiple values per arm: `$text = match($d) { 1, 2, 3, 4, 5 => "The week feels so long!", 6, 0 => "Weekends are best!", default => "Invalid day" };`. [S1]
- No match, no default → exception: `$favcolor = "pink"; try { $text = match($favcolor) { "red" => ..., "blue" => ..., "green" => ... }; } catch (\UnhandledMatchError $e) { var_dump($e); }`. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **match와 switch의 근본적 차이 4가지**: 값 반환 여부, 자동 break 여부, 엄격 비교(===) vs 느슨한 비교(==)가 명확히 구분됨. [S1]
## 🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — 값이 없을 때 UnhandledMatchError를 try-catch로 처리하는 패턴이 견고한 매치 로직의 실전 예시다. [S1]
## 💻 코드 패턴 (Code patterns)
Match expression with strict comparison and value return (PHP 8+):
```php
$favcolor = "red";
$text = match($favcolor) {
"red" => "Your favorite color is red!",
"blue" => "Your favorite color is blue!",
"green" => "Your favorite color is green!",
default => "Your favorite color is neither red, blue, nor green!",
};
echo $text;
```
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.90
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[PHP Tutorial]]
- **관련 개념:** [[PHP Switch]], [[PHP Exceptions]], [[PHP Looping]]
- **참조 맥락:** switch의 PHP 8 대안 — 반복문(Looping) 섹션으로 이어짐.
## 📚 출처 (Sources)
- [S1] W3Schools — PHP match Expression — https://www.w3schools.com/php/php_match.asp
## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP match Expression" page (Astra wiki-curation, P-Reinforce v3.1 format).