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,219 @@
|
||||
---
|
||||
id: php-tutorial-index
|
||||
title: "PHP Tutorial"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP Tutorial", "PHP MOC", "Topic_PHP index", "PHP 목차"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.90
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "moc", "index"]
|
||||
raw_sources: ["https://www.w3schools.com/php/"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Tutorial]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Map of Content (MOC) for the W3Schools PHP Tutorial — the root that links every core-PHP-language knowledge page in this topic folder. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- This folder (`Topic_PHP`) wikifies the core PHP language tutorial, one knowledge page per document, in P-Reinforce v3.1 format — same convention as `Topic_SQL` / `Topic_Python` / `Topic_Java` / `Topic_HTML` / `Topic_CSS` / `Topic_JavaScript`. [S1]
|
||||
- Scope: **tutorial pages only**. Explicitly **excluded**: reference dumps (`php_ref_*` index pages and all `func_*`/`keyword_*`/`ref_exception_*` detail pages), meta pages (Exam/Examples/Compiler/Quiz/Exercises/Server/Syllabus/Study Plan). [S1]
|
||||
- **Included despite overlapping category names**: `php_mysql_*` (PHP-specific mysqli usage, distinct from a general MYSQL category) and `php_xml_*` (PHP-specific XML parsing via SimpleXML/DOM/Expat, distinct from a general XML syntax category) and `php_json.asp` (PHP's json_encode/decode usage, distinct from a general JSON category) — same precedent as Python_MySQL/Python_MongoDB staying in Topic_Python. [S1]
|
||||
- **Progress:** **114 of 114 planned docs complete — PHP category done.**
|
||||
- Every page roots its Knowledge Graph back to this `[[PHP Tutorial]]` node.
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
|
||||
### Basics
|
||||
- [[PHP Intro]] ✅
|
||||
- [[PHP Install]] ✅
|
||||
- [[PHP Syntax]] ✅
|
||||
- [[PHP Comments]] ✅
|
||||
- [[PHP Comments Multiline]] ✅
|
||||
|
||||
### Variables & Output
|
||||
- [[PHP Variables]] ✅
|
||||
- [[PHP Variables Scope]] ✅
|
||||
- [[PHP Echo Print]] ✅
|
||||
- [[PHP Data Types]] ✅
|
||||
|
||||
### Strings
|
||||
- [[PHP Strings]] ✅
|
||||
- [[PHP String Functions]] ✅
|
||||
- [[PHP String Modify]] ✅
|
||||
- [[PHP String Concatenate]] ✅
|
||||
- [[PHP String Slicing]] ✅
|
||||
- [[PHP String Escape]] ✅
|
||||
|
||||
### Numbers & Math
|
||||
- [[PHP Numbers]] ✅
|
||||
- [[PHP Casting]] ✅
|
||||
- [[PHP Math]] ✅
|
||||
- [[PHP Constants]] ✅
|
||||
- [[PHP Magic Constants]] ✅
|
||||
|
||||
### Operators
|
||||
- [[PHP Operators]] ✅
|
||||
|
||||
### Conditions & Switch
|
||||
- [[PHP If Else]] ✅
|
||||
- [[PHP If Operators]] ✅
|
||||
- [[PHP If Else If]] ✅
|
||||
- [[PHP If Shorthand]] ✅
|
||||
- [[PHP If Nested]] ✅
|
||||
- [[PHP Switch]] ✅
|
||||
- [[PHP Match]] ✅
|
||||
|
||||
### Loops
|
||||
- [[PHP Looping]] ✅
|
||||
- [[PHP Looping While]] ✅
|
||||
- [[PHP Looping Do While]] ✅
|
||||
- [[PHP Looping For]] ✅
|
||||
- [[PHP Looping Foreach]] ✅
|
||||
- [[PHP Looping Break]] ✅
|
||||
- [[PHP Looping Continue]] ✅
|
||||
|
||||
### Functions
|
||||
- [[PHP Functions]] ✅
|
||||
|
||||
### Arrays
|
||||
- [[PHP Arrays]] ✅
|
||||
- [[PHP Arrays Indexed]] ✅
|
||||
- [[PHP Arrays Associative]] ✅
|
||||
- [[PHP Arrays Create]] ✅
|
||||
- [[PHP Arrays Access]] ✅
|
||||
- [[PHP Arrays Update]] ✅
|
||||
- [[PHP Arrays Add]] ✅
|
||||
- [[PHP Arrays Remove]] ✅
|
||||
- [[PHP Arrays Sort]] ✅
|
||||
- [[PHP Arrays Multidimensional]] ✅
|
||||
- [[PHP Arrays Functions]] ✅
|
||||
|
||||
### Superglobals
|
||||
- [[PHP Superglobals]] ✅
|
||||
- [[PHP Superglobals Globals]] ✅
|
||||
- [[PHP Superglobals Server]] ✅
|
||||
- [[PHP Superglobals Request]] ✅
|
||||
- [[PHP Superglobals Post]] ✅
|
||||
- [[PHP Superglobals Get]] ✅
|
||||
|
||||
### RegEx
|
||||
- [[PHP RegEx]] ✅
|
||||
- [[PHP RegEx Functions]] ✅
|
||||
|
||||
### Forms
|
||||
- [[PHP Forms]] ✅
|
||||
- [[PHP Form Validation]] ✅
|
||||
- [[PHP Form Required]] ✅
|
||||
- [[PHP Form URL Email]] ✅
|
||||
- [[PHP Form Complete]] ✅
|
||||
|
||||
### Date
|
||||
- [[PHP Date]] ✅
|
||||
|
||||
### Includes
|
||||
- [[PHP Includes]] ✅
|
||||
|
||||
### Files
|
||||
- [[PHP File]] ✅
|
||||
- [[PHP File Open]] ✅
|
||||
- [[PHP File Create]] ✅
|
||||
- [[PHP File Upload]] ✅
|
||||
|
||||
### Cookies & Sessions
|
||||
- [[PHP Cookies]] ✅
|
||||
- [[PHP Sessions]] ✅
|
||||
|
||||
### Filter
|
||||
- [[PHP Filter]] ✅
|
||||
- [[PHP Filter Advanced]] ✅
|
||||
|
||||
### Callback Functions
|
||||
- [[PHP Callback Functions]] ✅
|
||||
|
||||
### JSON
|
||||
- [[PHP JSON]] ✅
|
||||
|
||||
### Exceptions & Errors
|
||||
- [[PHP Exceptions]] ✅
|
||||
- [[PHP Error Handling]] ✅
|
||||
- [[PHP Exception]] ✅
|
||||
|
||||
### OOP
|
||||
- [[PHP OOP What Is]] ✅
|
||||
- [[PHP OOP Classes Objects]] ✅
|
||||
- [[PHP OOP Constructor]] ✅
|
||||
- [[PHP OOP Destructor]] ✅
|
||||
- [[PHP OOP Access Modifiers]] ✅
|
||||
- [[PHP OOP Inheritance]] ✅
|
||||
- [[PHP OOP Constants]] ✅
|
||||
- [[PHP OOP Classes Abstract]] ✅
|
||||
- [[PHP OOP Interfaces]] ✅
|
||||
- [[PHP OOP Traits]] ✅
|
||||
- [[PHP OOP Static Methods]] ✅
|
||||
- [[PHP OOP Static Properties]] ✅
|
||||
|
||||
### Namespaces & Iterables
|
||||
- [[PHP Namespaces]] ✅
|
||||
- [[PHP Iterables]] ✅
|
||||
|
||||
### MySQL
|
||||
- [[PHP MySQL Intro]] ✅
|
||||
- [[PHP MySQL Connect]] ✅
|
||||
- [[PHP MySQL Create DB]] ✅
|
||||
- [[PHP MySQL Create Table]] ✅
|
||||
- [[PHP MySQL Insert]] ✅
|
||||
- [[PHP MySQL Insert Last ID]] ✅
|
||||
- [[PHP MySQL Insert Multiple]] ✅
|
||||
- [[PHP MySQL Prepared Statements]] ✅
|
||||
- [[PHP MySQL Select]] ✅
|
||||
- [[PHP MySQL Select Where]] ✅
|
||||
- [[PHP MySQL Select Order By]] ✅
|
||||
- [[PHP MySQL Delete]] ✅
|
||||
- [[PHP MySQL Update]] ✅
|
||||
- [[PHP MySQL Select Limit]] ✅
|
||||
|
||||
### XML
|
||||
- [[PHP XML Parsers]] ✅
|
||||
- [[PHP XML SimpleXML Read]] ✅
|
||||
- [[PHP XML SimpleXML Get]] ✅
|
||||
- [[PHP XML Parser Expat]] ✅
|
||||
- [[PHP XML DOM]] ✅
|
||||
|
||||
### AJAX
|
||||
- [[PHP AJAX Intro]] ✅
|
||||
- [[PHP AJAX PHP]] ✅
|
||||
- [[PHP AJAX Database]] ✅
|
||||
- [[PHP AJAX XML]] ✅
|
||||
- [[PHP AJAX Live Search]] ✅
|
||||
- [[PHP AJAX Poll]] ✅
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
0 knowledge documents generated so far in this batch run.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[10_Wiki]]
|
||||
- **관련 개념:** [[PHP Intro]], [[PHP OOP What Is]], [[Java Tutorial]], [[Python Tutorial]], [[SQL Tutorial]]
|
||||
- **참조 맥락:** SQL/Python/Java에 이어 W3Schools 지식화 시리즈의 다음 카테고리.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Tutorial — https://www.w3schools.com/php/
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Created PHP Tutorial MOC with scope decisions and full planned page list (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-ajax-database
|
||||
title: "PHP AJAX Database"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["AJAX MySQL", "PHP AJAX 데이터베이스"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "ajax", "mysql"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_ajax_database.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP AJAX Database]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter is the exact same AJAX architecture as the name-autocomplete example, but with the PHP endpoint querying a REAL MySQL database instead of a hardcoded array — the JS-side `showUser()` function and event-handling boilerplate barely change, proving the AJAX pattern is agnostic to where the PHP script actually gets its data. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`onchange` event** (vs. `onkeyup` in the earlier example) — triggers on dropdown selection instead of every keystroke. [S1]
|
||||
- **Same AJAX skeleton** — `XMLHttpRequest` + `onreadystatechange` + query-string parameter passing, identical to the previous chapter. [S1]
|
||||
- **PHP-side database query** — `intval($_GET['q'])` sanitizes the ID as an integer, then a `SELECT * FROM user WHERE id = '$q'` query runs against MySQLi. [S1]
|
||||
- **Response is a rendered HTML table** — the PHP script builds `<table>` markup directly from the query results and echoes it, which JavaScript injects wholesale into the placeholder div. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Dropdown trigger: `<select name="users" onchange="showUser(this.value)">`. [S1]
|
||||
- PHP query and HTML table generation: `$q = intval($_GET['q']); $con = mysqli_connect('localhost','peter','abc123'); mysqli_select_db($con,"ajax_demo"); $sql="SELECT * FROM user WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); echo "<table>..."; while($row = mysqli_fetch_array($result)) { echo "<tr><td>" . $row['FirstName'] . "</td>...</tr>"; } echo "</table>";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 드롭다운에서 인물을 선택하면 MySQL에서 정보를 조회해 테이블로 보여주는 것이 AJAX-DB 연동의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
PHP endpoint querying MySQL and returning an HTML table for AJAX (PHP):
|
||||
```php
|
||||
$q = intval($_GET['q']);
|
||||
$con = mysqli_connect('localhost', 'peter', 'abc123');
|
||||
mysqli_select_db($con, "ajax_demo");
|
||||
$sql = "SELECT * FROM user WHERE id = '" . $q . "'";
|
||||
$result = mysqli_query($con, $sql);
|
||||
echo "<table>...";
|
||||
while ($row = mysqli_fetch_array($result)) {
|
||||
echo "<tr><td>" . $row['FirstName'] . "</td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP AJAX PHP]], [[PHP MySQL Select]], [[PHP AJAX XML]]
|
||||
- **참조 맥락:** AJAX+MySQL 연동 — XML 데이터 연동(AJAX XML) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - AJAX and MySQL — https://www.w3schools.com/php/php_ajax_database.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - AJAX and MySQL" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: php-ajax-intro
|
||||
title: "PHP AJAX Intro"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["AJAX 개요", "PHP AJAX 소개"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "ajax"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_ajax_intro.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP AJAX Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
AJAX's core value proposition is updating PART of a page WITHOUT reloading the WHOLE page — the source contrasts this directly against "classic web pages" that must reload entirely for any content change, using Google Suggest (2005) as the example that made this technique mainstream. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **AJAX** (Asynchronous JavaScript and XML) — exchanges small amounts of data with the server in the background, updating parts of a page without a full reload. [S1]
|
||||
- **Built on internet standards** — combines `XMLHttpRequest` (async server communication), JavaScript/DOM (display/interaction), CSS (styling), XML (data format). [S1]
|
||||
- **Browser/platform independent**. [S1]
|
||||
- **Real-world examples** — Google Maps, Gmail, YouTube, Facebook tabs, and Google Suggest (which popularized AJAX in 2005). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 챕터는 개념 소개 중심으로, PHP를 서버 스크립트로 사용하는 실전 예제는 다음 챕터부터 시작된다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Google Suggest가 AJAX를 대중화시킨 대표 사례로 언급된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
해당 챕터는 개념 소개 중심으로 별도 코드 예제가 없음 — 다음 챕터([[PHP AJAX PHP]])에서 실제 AJAX+PHP 코드가 시작된다.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP AJAX PHP]], [[PHP XML DOM]]
|
||||
- **참조 맥락:** AJAX 섹션의 도입부 — PHP와의 연동(AJAX PHP) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - AJAX Introduction — https://www.w3schools.com/php/php_ajax_intro.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - AJAX Introduction" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: php-ajax-live-search
|
||||
title: "PHP AJAX Live Search"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["실시간 검색", "PHP AJAX 라이브 서치"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "ajax", "xml", "search"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_ajax_livesearch.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP AJAX Live Search]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Live search is framed with three explicit UX benefits over traditional search — results appear WHILE typing, narrow AS you keep typing, and widen again if you delete characters — meaning the entire feature is really just the name-autocomplete pattern (onkeyup + XMLHttpRequest) applied to XML data with a link/title match instead of a name match. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Live search benefits** — instant results while typing, narrowing results with more input, broadening results by deleting characters. [S1]
|
||||
- **Same onkeyup pattern** — reuses the exact autocomplete architecture from `PHP AJAX PHP`. [S1]
|
||||
- **XML data source** — `links.xml`, containing `<link>` elements each with a `<title>` and `<url>` sub-element. [S1]
|
||||
- **PHP-side search via DOM + `stristr()`** — loads the XML with `DOMDocument`, then loops all `<link>` elements checking if the query string appears (case-insensitively) in each `<title>`. [S1]
|
||||
- **Response is pre-built HTML links** — matches are wrapped in `<a href="...">...</a>` tags directly by PHP before being sent back. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- PHP search loop: `$xmlDoc=new DOMDocument(); $xmlDoc->load("links.xml"); $x=$xmlDoc->getElementsByTagName('link'); $q=$_GET["q"]; if (strlen($q)>0) { for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { $hint = "<a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } } }`. [S1]
|
||||
- Fallback: `if ($hint=="") { $response="no suggestion"; } else { $response=$hint; } echo $response;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — W3Schools 페이지 링크를 실시간으로 검색해 클릭 가능한 링크로 반환하는 것이 실전 라이브 서치의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Case-insensitive title search returning pre-built HTML links (PHP/DOM):
|
||||
```php
|
||||
if (stristr($y->item(0)->childNodes->item(0)->nodeValue, $q)) {
|
||||
$hint = "<a href='" . $z->item(0)->childNodes->item(0)->nodeValue .
|
||||
"' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP AJAX XML]], [[PHP AJAX Poll]]
|
||||
- **참조 맥락:** onkeyup 실시간 검색 — 폴(AJAX Poll) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - AJAX Live Search — https://www.w3schools.com/php/php_ajax_livesearch.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - AJAX Live Search" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: php-ajax-php
|
||||
title: "PHP AJAX PHP"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["XMLHttpRequest", "PHP AJAX 자동완성"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "ajax", "javascript"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_ajax_php.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP AJAX PHP]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The classic autocomplete pattern splits work cleanly across the stack — JavaScript's `onkeyup` fires on every keystroke and sends the partial text via `XMLHttpRequest` to a PHP endpoint, while PHP does the actual matching against its name array and returns plain text that JavaScript drops straight into the DOM — meaning the PHP side never touches the DOM and the JS side never touches the data logic. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`onkeyup` event** — triggers the JavaScript function on every keystroke, enabling real-time feedback. [S1]
|
||||
- **`XMLHttpRequest`** — the JS object used to send the async GET request. [S1]
|
||||
- **`onreadystatechange`** — a callback fired when the request's state changes; checks `readyState == 4` (done) and `status == 200` (success) before using the response. [S1]
|
||||
- **Query string parameter passing** — the input's current value is appended to the request URL (`gethint.php?q=" + str`). [S1]
|
||||
- **PHP-side matching** — `$_REQUEST["q"]` retrieves the query string; `stristr()` performs a case-insensitive substring search against a hardcoded name array. [S1]
|
||||
- **Plain-text response** — the PHP script just `echo`s the matched name(s); no JSON/XML wrapping needed for this simple case. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- JS trigger: `<input type="text" id="fname" name="fname" onkeyup="showHint(this.value)">`. [S1]
|
||||
- Async request: `var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } }; xmlhttp.open("GET", "gethint.php?q=" + str, true); xmlhttp.send();`. [S1]
|
||||
- PHP matching: `$q = $_REQUEST["q"]; if ($q !== "") { $q = strtolower($q); $len=strlen($q); foreach($a as $name) { if (stristr($q, substr($name, 0, $len))) { ... } } } echo $hint === "" ? "no suggestion" : $hint;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이름 자동완성(입력 시 실시간 제안 표시)이 AJAX+PHP 연동의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
PHP-side substring matching against user input (PHP):
|
||||
```php
|
||||
$q = $_REQUEST["q"];
|
||||
$hint = "";
|
||||
if ($q !== "") {
|
||||
$q = strtolower($q);
|
||||
$len = strlen($q);
|
||||
foreach ($a as $name) {
|
||||
if (stristr($q, substr($name, 0, $len))) {
|
||||
$hint = ($hint === "") ? $name : $hint . ", $name";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $hint === "" ? "no suggestion" : $hint;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP AJAX Intro]], [[PHP AJAX Database]], [[PHP Superglobals Request]]
|
||||
- **참조 맥락:** JS-PHP 데이터 교환 기초 — 데이터베이스 연동(AJAX Database) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - AJAX and PHP — https://www.w3schools.com/php/php_ajax_php.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - AJAX and PHP" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-ajax-poll
|
||||
title: "PHP AJAX Poll"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP AJAX 투표"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "ajax", "file-handling"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_ajax_poll.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP AJAX Poll]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This poll persists its vote counts in a PLAIN TEXT FILE (`poll_result.txt`, format `"0||0"`), not a database — and the source explicitly warns to grant the WEB SERVER write access to that file, but NOT everyone, framing file permissions as the specific security concern for this simpler persistence approach. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`onclick` event** — triggers on radio button selection (vs. `onkeyup`/`onchange` in earlier chapters). [S1]
|
||||
- **Same AJAX skeleton** — `XMLHttpRequest` + `onreadystatechange`, now sending a `vote` parameter instead of a search string. [S1]
|
||||
- **File-based vote storage** — `poll_result.txt` stores counts as `"yesCount||noCount"`, parsed via `explode("||", $content[0])`. [S1]
|
||||
- **Read-modify-write cycle** — `file()` reads current counts, increments the relevant one, then `fopen()`+`fputs()`+`fclose()` overwrites the file with updated counts. [S1]
|
||||
- **Graphical percentage bars** — computed inline with `round($yes/($no+$yes),2)` and rendered as a proportionally-sized `<img>` width. [S1]
|
||||
- **File permission warning** — only the web server (PHP process) should have write access to `poll_result.txt`, not all users. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Read-modify-write vote logic: `$vote = $_REQUEST['vote']; $content = file($filename); $array = explode("||", $content[0]); $yes = $array[0]; $no = $array[1]; if ($vote == 0) { $yes = $yes + 1; } if ($vote == 1) { $no = $no + 1; } $insertvote = $yes."||".$no; $fp = fopen($filename,"w"); fputs($fp,$insertvote); fclose($fp);`. [S1]
|
||||
- Percentage bar rendering: `<img src="poll.gif" width='<?php echo(100*round($yes/($no+$yes),2)); ?>' height='20'> <?php echo(100*round($yes/($no+$yes),2)); ?>%`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **파일 쓰기 권한 경고**: poll_result.txt에 대한 쓰기 권한은 웹 서버(PHP)에만 부여해야 하며 모든 사용자에게 열어주면 안 된다는 점이 명시적으로 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 텍스트 파일로 투표수를 저장하고 그래픽 막대로 비율을 표시하는 것이 파일 기반 데이터 영속화의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Read-modify-write vote counting in a text file (PHP):
|
||||
```php
|
||||
$vote = $_REQUEST['vote'];
|
||||
$content = file("poll_result.txt");
|
||||
$array = explode("||", $content[0]);
|
||||
$yes = $array[0]; $no = $array[1];
|
||||
if ($vote == 0) { $yes = $yes + 1; }
|
||||
if ($vote == 1) { $no = $no + 1; }
|
||||
$fp = fopen("poll_result.txt", "w");
|
||||
fputs($fp, $yes."||".$no);
|
||||
fclose($fp);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP AJAX Live Search]], [[PHP Files Write]], [[PHP File Create]]
|
||||
- **참조 맥락:** AJAX 섹션이자 PHP 튜토리얼 전체의 마지막 챕터 — 파일 기반 데이터 저장을 실전 활용으로 마무리.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - AJAX Poll — https://www.w3schools.com/php/php_ajax_poll.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - AJAX Poll" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-ajax-xml
|
||||
title: "PHP AJAX XML"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["AJAX DOM XML", "PHP AJAX XML 연동"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "ajax", "xml", "dom"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_ajax_xml.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP AJAX XML]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The PHP endpoint has to do a two-step DOM search to find related data — first locate the `<ARTIST>` node matching the query, THEN walk UP to its `parentNode` to reach the sibling elements (title, year, etc.) that describe the same CD — because XML's tree structure means "find the artist" and "find everything about that artist's CD" are two separate traversal operations. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Same AJAX skeleton** — `onchange` + `XMLHttpRequest`, identical pattern to the database example. [S1]
|
||||
- **PHP-side XML search via `DOMDocument`** — `$xmlDoc->load("cd_catalog.xml"); $x = $xmlDoc->getElementsByTagName('ARTIST');` finds all artist nodes. [S1]
|
||||
- **`nodeType == 1`** — filters for actual ELEMENT nodes, excluding whitespace text nodes (same gotcha noted in the DOM Parser chapter). [S1]
|
||||
- **`->parentNode`** — navigates from a matched child node back up to its parent, to reach sibling data (title, year, price, etc. of the same CD). [S1]
|
||||
- **Building the response by iterating siblings** — once the parent CD node is found, its `childNodes` are looped to output each field. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Finding the matching artist's parent CD node: `$x = $xmlDoc->getElementsByTagName('ARTIST'); for ($i=0; $i<=$x->length-1; $i++) { if ($x->item($i)->nodeType==1) { if ($x->item($i)->childNodes->item(0)->nodeValue == $q) { $y=($x->item($i)->parentNode); } } }`. [S1]
|
||||
- Outputting all sibling fields of the matched CD: `$cd=($y->childNodes); for ($i=0;$i<$cd->length;$i++) { if ($cd->item($i)->nodeType==1) { echo("<b>" . $cd->item($i)->nodeName . ":</b> "); echo($cd->item($i)->childNodes->item(0)->nodeValue); echo("<br>"); } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — CD 카탈로그 XML에서 아티스트명으로 검색해 앨범 정보를 반환하는 것이 DOM 기반 XML 검색의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Finding a matching node then navigating to its parent for sibling data (PHP/DOM):
|
||||
```php
|
||||
$x = $xmlDoc->getElementsByTagName('ARTIST');
|
||||
for ($i = 0; $i <= $x->length - 1; $i++) {
|
||||
if ($x->item($i)->nodeType == 1) {
|
||||
if ($x->item($i)->childNodes->item(0)->nodeValue == $q) {
|
||||
$y = $x->item($i)->parentNode; // step up to sibling data
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP AJAX Database]], [[PHP XML DOM]], [[PHP AJAX Live Search]]
|
||||
- **참조 맥락:** DOM 기반 XML 검색 — 실시간 검색(AJAX Live Search) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Example - AJAX and XML — https://www.w3schools.com/php/php_ajax_xml.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Example - AJAX and XML" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: php-arrays
|
||||
title: "PHP Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["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", "arrays"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A single PHP array can freely mix data types AND nest other arrays inside it (`array("Volvo", 15, ["apples", "bananas"])`) — unlike strictly-typed array languages, PHP places no constraint on element type uniformity, treating arrays/objects/functions as equally valid array items alongside strings and numbers. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Array** — a special variable holding multiple values under one name, accessed by index or key. [S1]
|
||||
- **Three array types** — indexed (numeric index), associative (named keys), multidimensional (arrays of arrays). [S1]
|
||||
- **Mixed-type items** — an array can hold strings, numbers, objects, functions, or other arrays simultaneously. [S1]
|
||||
- **`count()`** — returns the number of items in an array. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic array: `$cars = array("Volvo", "BMW", "Toyota");`. [S1]
|
||||
- Mixed types with nested array: `$myArr = array("Volvo", 15, ["apples", "bananas"]);`. [S1]
|
||||
- Counting: `echo count($cars);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 서로 다른 데이터 타입을 하나의 배열에 섞어 저장하는 것이 PHP 배열의 유연성을 보여주는 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Array holding mixed data types including a nested array (PHP):
|
||||
```php
|
||||
$myArr = array("Volvo", 15, ["apples", "bananas"]);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Indexed]], [[PHP Arrays Associative]], [[PHP Arrays Multidimensional]]
|
||||
- **참조 맥락:** 배열 전체 섹션의 도입부 — 인덱스 배열(Indexed) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Arrays — https://www.w3schools.com/php/php_arrays.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-arrays-access
|
||||
title: "PHP Arrays Access"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP 배열 접근"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "arrays", "access"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_access.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Access]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An array item can hold a function NAME as a string, and calling `$myArr[2]()` actually invokes that named function — this dynamic-call pattern (storing a callable's name and invoking it via array access + parentheses) is a lightweight precursor to PHP's full callback-function mechanism covered later. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Access by index (indexed array)** — `$cars[2]`. [S1]
|
||||
- **Access by key (associative array)** — `$cars["year"]`. [S1]
|
||||
- **Double or single quotes** — both work identically for key access: `$cars["model"]` / `$cars['model']`. [S1]
|
||||
- **Executing a function stored as an array item** — `$myArr[2]();` calls the function whose name is stored at that index. [S1]
|
||||
- **`foreach`** — standard iteration for both indexed and associative arrays. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Indexed access: `$cars = array("Volvo", "BMW", "Toyota"); echo $cars[2]; // "Toyota"`. [S1]
|
||||
- Associative access: `$cars = array("brand" => "Ford", "model" => "Mustang", "year" => 1964); echo $cars["year"];`. [S1]
|
||||
- Function-name-as-array-item, invoked: `function myFunction() { echo "I come from a function!"; } $myArr = array("Volvo", 15, "myFunction"); $myArr[2]();`. [S1]
|
||||
- Same pattern via associative key: `$myArr = array("car" => "Volvo", "age" => 15, "message" => "myFunction"); $myArr["message"]();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 배열에 저장된 함수 이름을 인덱스로 호출하는 패턴이 콜백 함수(Callback Functions) 챕터로 이어지는 예고편이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Invoking a function whose name is stored as an array item (PHP):
|
||||
```php
|
||||
function myFunction() {
|
||||
echo "I come from a function!";
|
||||
}
|
||||
$myArr = array("Volvo", 15, "myFunction");
|
||||
$myArr[2](); // calls myFunction()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Create]], [[PHP Arrays Update]], [[PHP Callback Functions]]
|
||||
- **참조 맥락:** 배열 항목 접근 및 함수 실행 — 배열 수정(Update) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Access Arrays — https://www.w3schools.com/php/php_arrays_access.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Access Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-arrays-add
|
||||
title: "PHP Arrays Add"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["array_push", "array_unshift", "array_merge", "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", "arrays", "add"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_add.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Add]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Adding multiple items to an associative array requires the `+=` operator instead of `array_push()` — `array_push()` only works with numeric-indexed arrays, so associative arrays need their own dedicated pattern (`$cars += ["color" => "red", "year" => 1964];`) to bulk-add named key-value pairs. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`[]` bracket append** — `$fruits[] = "Orange";` adds a single item to the end. [S1]
|
||||
- **`array_push($arr, ...)`** — adds one or more items to the end (indexed arrays). [S1]
|
||||
- **`+=` for associative bulk-add** — merges new key-value pairs into an associative array. [S1]
|
||||
- **`array_unshift($arr, ...)`** — adds one or more items to the BEGINNING. [S1]
|
||||
- **`array_splice($arr, offset, 0, item)`** — inserting with a length of 0 means nothing is removed, only inserted. [S1]
|
||||
- **`array_merge($arr1, $arr2, ...)`** — combines two or more arrays into one. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single append: `$fruits = array("Apple", "Banana", "Cherry"); $fruits[] = "Orange";`. [S1]
|
||||
- Associative single-add: `$cars = array("brand" => "Ford", "model" => "Mustang"); $cars["color"] = "Red";`. [S1]
|
||||
- array_push (multiple, indexed): `array_push($fruits, "Orange", "Kiwi", "Lemon");`. [S1]
|
||||
- Associative bulk-add: `$cars += ["color" => "red", "year" => 1964];`. [S1]
|
||||
- array_unshift (prepend multiple): `array_unshift($fruits, "Orange", "Kiwi", "Lemon");`. [S1]
|
||||
- array_splice insert-only: `array_splice($fruits, 1, 0, "Orange"); // inserts at index 1, removes nothing`. [S1]
|
||||
- array_merge: `$result = array_merge($fruits1, $fruits2);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **연관 배열 다중 추가의 특수성**: array_push()는 인덱스 배열용이므로 연관 배열에 여러 키-값 쌍을 한 번에 추가하려면 += 연산자를 써야 한다는 점이 구분됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — array_splice()로 특정 위치에 항목을 삽입하는 것이 배열 중간 삽입의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Bulk-adding key-value pairs to an associative array (PHP):
|
||||
```php
|
||||
$cars = array("brand" => "Ford", "model" => "Mustang");
|
||||
$cars += ["color" => "red", "year" => 1964];
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Update]], [[PHP Arrays Remove]], [[PHP Arrays Functions]]
|
||||
- **참조 맥락:** 배열 항목 추가 방법 — 항목 삭제(Remove) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Add Array Items — https://www.w3schools.com/php/php_arrays_add.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Add Array Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: php-arrays-associative
|
||||
title: "PHP Arrays Associative"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["associative arrays", "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", "arrays", "associative"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_associative.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Associative]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `foreach ($car as $key => $value)` two-variable form is what makes associative arrays actually useful in loops — without capturing the key, you'd only get the values back with no way to know which named field each one came from, unlike indexed arrays where position alone is often sufficient context. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Associative array** — uses named keys (`"brand" => "Ford"`) instead of numeric indices. [S1]
|
||||
- **`=>` operator** — separates key from value in array literals. [S1]
|
||||
- **Access/update by key name** — `$car["model"]` reads or writes via the key. [S1]
|
||||
- **`foreach ($arr as $key => $value)`** — the two-variable loop form, exposing both key and value per iteration. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create: `$car = array("brand"=>"Ford", "model"=>"Mustang", "year"=>1964);`. [S1]
|
||||
- Access: `echo $car["model"]; // "Mustang"`. [S1]
|
||||
- Update: `$car["year"] = 2024;`. [S1]
|
||||
- Loop with key+value: `foreach ($car as $x => $y) { echo "$x: $y <br>"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차의 브랜드/모델/연도처럼 명명된 속성 집합을 표현하는 것이 연관 배열의 대표 활용이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Looping with key and value together (PHP):
|
||||
```php
|
||||
$car = array("brand"=>"Ford", "model"=>"Mustang", "year"=>1964);
|
||||
foreach ($car as $x => $y) {
|
||||
echo "$x: $y <br>";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Indexed]], [[PHP Arrays Create]], [[PHP Looping Foreach]]
|
||||
- **참조 맥락:** 명명된 키 기반 배열 — 배열 생성(Create) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Associative Arrays — https://www.w3schools.com/php/php_arrays_associative.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Associative Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-arrays-create
|
||||
title: "PHP Arrays Create"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["array() vs []", "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", "arrays", "create"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_create.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Create]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Indexed and associative arrays are structurally IDENTICAL under the hood — an indexed array is just an associative array whose keys happen to be auto-assigned sequential integers (`0 => "Volvo", 1 => "BMW"`), and you can even mix numeric and named keys freely in the same array, since PHP doesn't enforce a hard boundary between the two "types." [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`array()`** vs **`[]`** — functionally identical; brackets are the shorter modern syntax. [S1]
|
||||
- **Multi-line declarations** — line breaks don't matter inside an array literal. [S1]
|
||||
- **Trailing comma** — allowed after the last item. [S1]
|
||||
- **Auto-assigned indices** — indexed arrays are secretly `0 => val, 1 => val, ...` associative arrays. [S1]
|
||||
- **Empty array + incremental fill** — `$cars = []; $cars[0] = "Volvo"; ...`. [S1]
|
||||
- **Mixed keys** — an array can combine numeric indices and named keys simultaneously. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Shorthand brackets: `$cars = ["Volvo", "BMW", "Toyota"];`. [S1]
|
||||
- Explicit index-key equivalence: `$cars = [0 => "Volvo", 1 => "BMW", 2 =>"Toyota"];` — same as auto-indexed. [S1]
|
||||
- Empty then fill (indexed): `$cars = []; $cars[0] = "Volvo"; $cars[1] = "BMW"; $cars[2] = "Toyota";`. [S1]
|
||||
- Empty then fill (associative): `$myCar = []; $myCar["brand"] = "Ford"; $myCar["model"] = "Mustang";`. [S1]
|
||||
- Mixed keys: `$myArr = []; $myArr[0] = "apples"; $myArr[1] = "bananas"; $myArr["fruit"] = "cherries";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **인덱스 배열과 연관 배열의 구조적 동일성**: 인덱스 배열은 사실 숫자 키(0, 1, 2...)를 자동 할당받은 연관 배열일 뿐이라는 점이 예제로 직접 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 숫자 인덱스와 명명된 키를 한 배열에 혼용하는 패턴이 유연한 데이터 구조 설계의 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Mixed numeric and named keys in one array (PHP):
|
||||
```php
|
||||
$myArr = [];
|
||||
$myArr[0] = "apples";
|
||||
$myArr[1] = "bananas";
|
||||
$myArr["fruit"] = "cherries";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Indexed]], [[PHP Arrays Associative]], [[PHP Arrays Access]]
|
||||
- **참조 맥락:** 배열 생성 문법 — 배열 접근(Access) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Create Arrays — https://www.w3schools.com/php/php_arrays_create.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Create Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: php-arrays-functions
|
||||
title: "PHP Arrays Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["array function reference", "PHP 배열 함수 목록"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "arrays", "functions", "reference"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter is a single comprehensive index of ~80 built-in array functions, revealing that PHP has dedicated functions for operations most languages leave to manual loops — `array_intersect()`, `array_diff()`, `array_flip()`, `array_product()`, and `array_walk()` each replace what would otherwise be several lines of loop logic with one function call. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Comparison functions** — `array_diff()`/`array_intersect()` families (with `_assoc`, `_key`, `_uassoc`, `_ukey` variants) compare arrays by value, key, or both, with optional custom comparison callbacks. [S1]
|
||||
- **Transformation functions** — `array_map()` (apply a function to every value), `array_filter()` (keep values matching a callback), `array_walk()` (apply a function in place), `array_flip()` (swap keys and values). [S1]
|
||||
- **Aggregation functions** — `array_sum()`, `array_product()`, `array_count_values()`. [S1]
|
||||
- **Structural functions** — `array_chunk()`, `array_slice()`, `array_splice()`, `array_pad()`, `array_reverse()`, `array_unique()`. [S1]
|
||||
- **Lookup functions** — `in_array()`, `array_key_exists()`, `array_search()`. [S1]
|
||||
- **Pointer functions** — `current()`, `next()`, `prev()`, `reset()`, `end()`, `key()` — manage an array's internal cursor. [S1]
|
||||
- **`each()`** — deprecated since PHP 7.2. [S1]
|
||||
- **`sizeof()`** — alias of `count()`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 챕터는 함수명+한 줄 설명으로 구성된 레퍼런스 표이며, 개별 함수의 상세 사용법은 W3Schools의 별도 PHP Array Reference에서 다룬다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — array_map()으로 배열의 모든 값에 함수를 일괄 적용하는 것이 함수형 배열 처리의 대표 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
해당 챕터는 함수 목록 레퍼런스이며 별도 코드 예제 없음 — Superglobals 섹션으로 이어짐.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Sort]], [[PHP Arrays Multidimensional]], [[PHP Superglobals]]
|
||||
- **참조 맥락:** 배열 섹션의 최종 레퍼런스 — Superglobals 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Array Functions — https://www.w3schools.com/php/php_arrays_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Array Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-arrays-indexed
|
||||
title: "PHP Arrays Indexed"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["indexed arrays", "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", "arrays", "indexed"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_indexed.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Indexed]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Indexed arrays follow the universal 0-based convention (first item = index 0), and modifying an item just requires reassigning `$array[index] = newValue` — the same bracket syntax used for reading doubles as the syntax for writing, with no separate "setter" method needed. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Indexed array** — each item has a numeric index, starting at 0. [S1]
|
||||
- **Access by index** — `$cars[0]` reads the first item. [S1]
|
||||
- **Update by index** — `$cars[1] = "Ford";` overwrites the second item. [S1]
|
||||
- **`foreach`** — the standard way to loop through all values. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create + inspect: `$cars = array("Volvo", "BMW", "Toyota"); var_dump($cars);`. [S1]
|
||||
- Access: `echo $cars[0]; // "Volvo"`. [S1]
|
||||
- Update: `$cars[1] = "Ford"; var_dump($cars);`. [S1]
|
||||
- Loop: `foreach ($cars as $x) { echo "$x <br>"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — foreach로 인덱스 배열 전체를 순회 출력하는 것이 가장 기본적인 실전 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Updating an item by index, then looping (PHP):
|
||||
```php
|
||||
$cars = array("Volvo", "BMW", "Toyota");
|
||||
$cars[1] = "Ford";
|
||||
foreach ($cars as $x) {
|
||||
echo "$x <br>";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays]], [[PHP Arrays Associative]], [[PHP Looping Foreach]]
|
||||
- **참조 맥락:** 숫자 인덱스 배열의 기초 — 연관 배열(Associative) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Indexed Arrays — https://www.w3schools.com/php/php_arrays_indexed.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Indexed Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-arrays-multidimensional
|
||||
title: "PHP Arrays Multidimensional"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["multidimensional arrays", "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", "arrays", "multidimensional"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_multidimensional.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Multidimensional]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP explicitly warns that arrays nested more than THREE levels deep become "hard to manage for most people" — even though PHP technically supports arbitrary nesting depth, the tutorial itself sets a practical human-comprehension limit rather than a technical one. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Multidimensional array** — an array containing one or more arrays. [S1]
|
||||
- **Two-dimensional array** — an array of arrays, needing TWO indices (row, column) to reach an element. [S1]
|
||||
- **Dimension = index count** — a 3D array needs 3 indices per element, and so on. [S1]
|
||||
- **Nested loops for traversal** — a `for` inside a `for`, or `foreach` inside a `foreach`, to visit every cell. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- 2D array representing a table: `$cars = array( array("Volvo", 22, 18), array("BMW", 15, 13), array("Saab", 5, 2), array("Land Rover", 17, 15) );`. [S1]
|
||||
- Element access with two indices: `echo $cars[0][0].": In stock: ".$cars[0][1].", sold: ".$cars[0][2].".<br>";`. [S1]
|
||||
- Nested for loops: `for ($row = 0; $row < 4; $row++) { for ($col = 0; $col < 3; $col++) { echo $cars[$row][$col]; } }`. [S1]
|
||||
- Nested foreach loops building an HTML table: `foreach ($cars as $row) { foreach ($row as $cell) { echo "<td>" . $cell . "</td>"; } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **실용적 깊이 제한 경고**: PHP는 다차원 배열을 기술적으로 무제한 지원하지만, 3단계 이상 중첩은 대부분 사람에게 관리하기 어렵다고 명시적으로 경고함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차 재고/판매 테이블을 2차원 배열로 표현하고 HTML 테이블로 렌더링하는 것이 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Nested foreach building an HTML table from a 2D array (PHP):
|
||||
```php
|
||||
echo "<table>";
|
||||
foreach ($cars as $row) {
|
||||
echo "<tr>";
|
||||
foreach ($row as $cell) {
|
||||
echo "<td>" . $cell . "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Sort]], [[PHP Arrays Functions]], [[PHP Looping For]]
|
||||
- **참조 맥락:** 2차원 이상 배열 구조 — 배열 함수(Functions) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Multidimensional Arrays — https://www.w3schools.com/php/php_arrays_multidimensional.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Multidimensional Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-arrays-remove
|
||||
title: "PHP Arrays Remove"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["unset", "array_splice", "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", "arrays", "remove", "unset"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_remove.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Remove]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`array_splice()` and `unset()` handle re-indexing completely differently — `array_splice()` automatically re-indexes the array from 0 after removal, while `unset()` leaves a GAP in the index sequence (removing index 1 leaves indices 0, 2, 3... with no 1), a distinction that matters if code later assumes contiguous indices. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`array_splice($arr, start, length)`** — removes a portion and auto-re-indexes from 0. [S1]
|
||||
- **`unset($arr[key])`** — removes one item by key/index; does NOT re-index, leaving gaps. [S1]
|
||||
- **`unset()` accepts multiple arguments** — can remove several items in one call. [S1]
|
||||
- **`array_diff($arr, [values])`** — returns a NEW array excluding specified VALUES (not keys). [S1]
|
||||
- **`array_pop($arr)`** — removes the last item. [S1]
|
||||
- **`array_shift($arr)`** — removes the first item. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- array_splice (re-indexes): `$cars = array("Volvo", "BMW", "Toyota"); array_splice($cars, 1, 1); // removes "BMW", re-indexed to [0=>"Volvo", 1=>"Toyota"]`. [S1]
|
||||
- unset (leaves a gap): `$cars = array("Volvo", "BMW", "Toyota"); unset($cars[1]); // [0=>"Volvo", 2=>"Toyota"] — no index 1`. [S1]
|
||||
- unset multiple: `unset($cars[0], $cars[1]);`. [S1]
|
||||
- unset by key (associative): `unset($cars["model"]);`. [S1]
|
||||
- array_diff (value-based removal): `$newarray = array_diff($cars, ["Mustang", 1964]); // note: values, not keys`. [S1]
|
||||
- array_pop / array_shift: `array_pop($cars); // removes last`; `array_shift($cars); // removes first`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **재인덱싱 여부의 차이**: array_splice()는 삭제 후 0부터 자동 재인덱싱하지만, unset()은 재인덱싱하지 않아 인덱스에 공백이 생긴다는 점이 명확히 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — array_diff()로 특정 값들을 제외한 새 배열을 만드는 패턴이 연관 배열 필터링의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
unset() leaves an index gap, unlike array_splice() (PHP):
|
||||
```php
|
||||
$cars = array("Volvo", "BMW", "Toyota");
|
||||
unset($cars[1]);
|
||||
var_dump($cars); // [0]=>"Volvo", [2]=>"Toyota" — index 1 is missing, not re-indexed
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Add]], [[PHP Arrays Sort]], [[PHP Arrays Functions]]
|
||||
- **참조 맥락:** 배열 항목 삭제 — 정렬(Sort) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Delete Array Items — https://www.w3schools.com/php/php_arrays_remove.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Delete Array Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-arrays-sort
|
||||
title: "PHP Arrays Sort"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["sort", "ksort", "asort", "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", "arrays", "sorting"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_sort.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Sort]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Sorting an associative array requires choosing whether to sort by KEY or by VALUE as two entirely separate function families — `asort()`/`arsort()` sort by value while `ksort()`/`krsort()` sort by key, meaning "sort this associative array" is an ambiguous request in PHP that must be resolved to one of four specific functions. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`sort()`** — indexed array, ascending. [S1]
|
||||
- **`rsort()`** — indexed array, descending. [S1]
|
||||
- **`asort()`** — associative array, ascending BY VALUE. [S1]
|
||||
- **`ksort()`** — associative array, ascending BY KEY. [S1]
|
||||
- **`arsort()`** — associative array, descending BY VALUE. [S1]
|
||||
- **`krsort()`** — associative array, descending BY KEY. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- sort (strings): `$cars = array("Volvo", "BMW", "Toyota"); sort($cars); print_r($cars); // alphabetical`. [S1]
|
||||
- sort (numbers): `$numbers = array(4, 6, 2, 22, 11); sort($numbers); // ascending numeric`. [S1]
|
||||
- rsort: `rsort($cars); // descending alphabetical`. [S1]
|
||||
- asort (by value): `$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43"); asort($age); // sorted by age value, ascending`. [S1]
|
||||
- ksort (by key): `ksort($age); // sorted by name key, alphabetically ascending`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **키 정렬 vs 값 정렬의 명확한 분리**: 연관 배열 정렬은 값 기준(asort/arsort)과 키 기준(ksort/krsort)이 완전히 다른 함수로 분리되어 있다는 점이 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 나이순으로 사람 목록을 정렬(asort)하거나 이름순으로 정렬(ksort)하는 것이 실전 활용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Sorting an associative array by value vs. by key (PHP):
|
||||
```php
|
||||
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
|
||||
asort($age); // sort by value (age), ascending
|
||||
ksort($age); // sort by key (name), ascending
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Remove]], [[PHP Arrays Multidimensional]], [[PHP Arrays Functions]]
|
||||
- **참조 맥락:** 배열 정렬 함수 6종 — 다차원 배열(Multidimensional) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Sorting Arrays — https://www.w3schools.com/php/php_arrays_sort.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Sorting Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-arrays-update
|
||||
title: "PHP Arrays Update"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["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", "arrays", "update", "unset"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_arrays_update.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Arrays Update]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Forgetting `unset($x)` after a by-reference foreach loop is a genuine bug trap — the source demonstrates it directly: after the loop, `$x` STILL points at the array's last element, so a later `$x = "ice cream";` silently overwrites that last array element too, even though the loop has already finished. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Update by index/key** — same syntax as access: `$cars[1] = "Ford";` or `$cars["year"] = 2024;`. [S1]
|
||||
- **By-reference foreach for bulk update** — `foreach ($cars as &$x) { $x = "Ford"; }` mutates every element of the original array. [S1]
|
||||
- **`unset($x)` after the loop is mandatory** — without it, `$x` remains a reference to the array's last element, and any later reassignment of `$x` silently corrupts that array element. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic index update: `$cars = array("Volvo", "BMW", "Toyota"); $cars[1] = "Ford";`. [S1]
|
||||
- Basic key update: `$cars = array("brand" => "Ford", ...); $cars["year"] = 2024;`. [S1]
|
||||
- Bulk by-reference update: `foreach ($cars as &$x) { $x = "Ford"; } unset($x);` — all items become "Ford". [S1]
|
||||
- Bug demonstration (unset omitted): `foreach ($cars as &$x) { $x = "Ford"; } $x = "ice cream"; var_dump($cars); // last element of $cars is now "ice cream"!`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **unset() 생략의 위험**: 참조 반복 후 unset()을 호출하지 않으면 $x가 배열의 마지막 요소를 계속 참조하며, 이후 $x를 재할당하면 배열이 의도치 않게 변경된다는 점이 버그 예제로 직접 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — foreach 참조 반복 후 unset()을 빠뜨리는 것이 실전에서 자주 발생하는 버그 패턴이므로 반드시 기억해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Forgetting unset() after a by-reference loop corrupts the array (PHP):
|
||||
```php
|
||||
$cars = array("Volvo", "BMW", "Toyota");
|
||||
foreach ($cars as &$x) {
|
||||
$x = "Ford";
|
||||
}
|
||||
$x = "ice cream"; // BUG: $x still references $cars' last element!
|
||||
var_dump($cars); // last element is now "ice cream", not "Ford"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays Access]], [[PHP Looping Foreach]], [[PHP Arrays Add]]
|
||||
- **참조 맥락:** 배열 항목 수정 — 항목 추가(Add) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Update Array Items — https://www.w3schools.com/php/php_arrays_update.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Update Array Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: php-callback-functions
|
||||
title: "PHP Callback Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["anonymous function callback", "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", "callback", "functions"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_callback_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Callback Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A named function used as a callback is passed as a plain STRING ("myfunction"), not as a special function-reference syntax — meaning any existing function automatically qualifies as a callback with zero extra syntax, while anonymous functions are defined inline specifically for one-off, unnamed use cases. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Callback function** — a function passed as an argument into another function. [S1]
|
||||
- **Named function callback** — pass the function's name as a string: `array_map("myfunction", $numbers)`. [S1]
|
||||
- **Anonymous function callback** — defined inline: `array_map(function($n) {return($n * $n);}, $numbers)`. [S1]
|
||||
- **Callbacks in user-defined functions** — a parameter holding a function is invoked by adding parentheses: `$format($str)`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Named function as callback: `function myfunction($n) { return($n * $n); } $numbers = [1, 2, 3, 4, 5]; print_r(array_map("myfunction", $numbers));`. [S1]
|
||||
- Anonymous function as callback: `$res = array_map(function($n) {return($n * $n);}, $numbers);`. [S1]
|
||||
- Callback passed to a user-defined function: `function printFormatted($str, $format) { echo $format($str); } printFormatted("Hello world", "exclaim"); printFormatted("Hello world", "ask");` (where `exclaim` and `ask` are separately-defined named functions). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — array_map()에 콜백을 전달해 배열의 모든 요소를 변환하는 것이 함수형 스타일 배열 처리의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
User-defined function accepting a callback (PHP):
|
||||
```php
|
||||
function exclaim($str) { return $str . "! "; }
|
||||
function printFormatted($str, $format) {
|
||||
echo $format($str);
|
||||
}
|
||||
printFormatted("Hello world", "exclaim");
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Filter Advanced]], [[PHP JSON]], [[PHP Arrays Functions]]
|
||||
- **참조 맥락:** 함수를 인자로 전달하는 패턴 — JSON 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Callback Functions — https://www.w3schools.com/php/php_callback_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Callback Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: php-casting
|
||||
title: "PHP Casting"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["type casting", "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", "casting", "types"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_casting.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Casting]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Casting an object to an array converts its property names into array keys automatically (`(array) $myCar` turns `color`/`model` properties into `["color" => ..., "model" => ...]`) — this reversible object↔associative-array relationship is a core mechanic for interoperating between OOP and plain data structures in PHP. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Casting operators** — `(string)`, `(int)`, `(float)`, `(bool)`, `(array)`, `(object)`, `(unset)` (deprecated in 7.2, removed in 8.0). [S1]
|
||||
- **Bool cast rule** — `0`, `NULL`, `false`, `""` (empty string) convert to `false`; everything else (even `-1`) converts to `true`. [S1]
|
||||
- **Array cast on scalars** — most types become a single-element indexed array. [S1]
|
||||
- **Array cast on objects** — becomes an associative array with property names as keys. [S1]
|
||||
- **Object cast on scalars** — becomes an object with one property named `"scalar"`. [S1]
|
||||
- **Object cast on arrays** — indexed arrays get numeric-index property names; associative arrays keep their keys as property names. [S1]
|
||||
- **NULL casting** — the deprecated/removed `(unset)` operator is replaced by simply assigning `NULL` directly. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Bool falsy values: `$c = 0; $g = ""; // both cast to false`, while `$d = -1; // casts to true`. [S1]
|
||||
- Object → array: `class Car { public $color; public $model; ... } $myCar = new Car("red", "Volvo"); $myCar = (array) $myCar; var_dump($myCar); // ["color" => "red", "model" => "Volvo"]`. [S1]
|
||||
- Indexed array → object: `$a = array("Volvo", "BMW", "Toyota"); $a = (object) $a; // properties named 0, 1, 2`. [S1]
|
||||
- Associative array → object: `$b = array("Peter"=>"35", "Ben"=>"37"); $b = (object) $b; // properties named Peter, Ben`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **(unset) 캐스팅 지원 중단**: PHP 7.2.0에서 지원 중단(deprecated), PHP 8.0.0에서 완전히 제거됨 — 대신 변수에 NULL을 직접 할당하는 방식 사용. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 객체를 연관 배열로 변환하는 패턴이 데이터 직렬화/디버깅에서 자주 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Casting an object to an associative array (PHP):
|
||||
```php
|
||||
class Car {
|
||||
public $color;
|
||||
public $model;
|
||||
public function __construct($color, $model) {
|
||||
$this->color = $color;
|
||||
$this->model = $model;
|
||||
}
|
||||
}
|
||||
$myCar = new Car("red", "Volvo");
|
||||
$myCar = (array) $myCar;
|
||||
var_dump($myCar); // ["color" => "red", "model" => "Volvo"]
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Numbers]], [[PHP Data Types]], [[PHP OOP Classes Objects]], [[PHP Arrays]]
|
||||
- **참조 맥락:** 명시적 타입 변환 — 수학함수(Math) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Type Casting — https://www.w3schools.com/php/php_casting.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Type Casting" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-comments
|
||||
title: "PHP Comments"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP 주석"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "comments"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_comments.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Comments]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP uniquely supports TWO single-line comment styles (`//` and `#`) where most languages offer just one — both are fully interchangeable and equally legal, a flexibility inherited from PHP's C-style (`//`) and shell-script-style (`#`) heritage. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Single-line comments** — `//` or `#`; everything to end-of-line is ignored. [S1]
|
||||
- **Multi-line comments** — `/* ... */`. [S1]
|
||||
- **Purposes** — explain code to others, remind yourself later, temporarily disable code for testing. [S1]
|
||||
- **Ignoring code via comments** — commenting out a line prevents its execution. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Two single-line styles: `// This is a single-line comment` and `# This is also a single-line comment`. [S1]
|
||||
- Comment before code: `// Output welcome message echo 'Welcome Home!';`. [S1]
|
||||
- Comment at line end: `echo 'Welcome Home!'; // Output welcome message`. [S1]
|
||||
- Disabling code: `// echo 'Welcome Home!';` — the echo never runs. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 테스트 중 특정 코드 줄을 비활성화하는 용도로 주석이 자주 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two equivalent single-line comment styles (PHP):
|
||||
```php
|
||||
// This is a single-line comment
|
||||
# This is also a single-line comment
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Syntax]], [[PHP Comments Multiline]]
|
||||
- **참조 맥락:** 한 줄 주석 문법 — 여러 줄 주석(Multiline) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Comments — https://www.w3schools.com/php/php_comments.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Comments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: php-comments-multiline
|
||||
title: "PHP Comments Multiline"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP 여러 줄 주석"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "comments"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_comments_multiline.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Comments Multiline]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Multi-line comment syntax (`/* ... */`) can be embedded MID-STATEMENT, not just around whole lines — `$x = 5 /* + 15 */ + 5;` shows the comment silently removing a piece of an expression, letting you selectively "comment out" a sub-part of a calculation without touching the rest of the line. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`/* ... */`** — multi-line comment; all text between the delimiters is ignored. [S1]
|
||||
- **Block-disabling** — wrapping multiple lines of code in `/* */` disables the entire block at once. [S1]
|
||||
- **Mid-expression use** — the same syntax can remove just a fragment of a single line/expression. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Explanatory comment: `/* The next statement will print a welcome message */ echo 'Welcome Home!';`. [S1]
|
||||
- Disabling a code block: `/* echo 'Welcome to my home!'; echo 'Mi casa su casa!'; */ echo 'Hello!';` — only "Hello!" prints. [S1]
|
||||
- Mid-line fragment removal: `$x = 5 /* + 15 */ + 5; echo $x; // 10, not 25`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 계산식 일부를 임시로 제외하고 테스트하는 것이 실전에서 자주 쓰이는 디버깅 기법이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Mid-expression comment removing part of a calculation (PHP):
|
||||
```php
|
||||
$x = 5 /* + 15 */ + 5;
|
||||
echo $x; // 10
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Comments]], [[PHP Variables]]
|
||||
- **참조 맥락:** 여러 줄 주석 — 변수(Variables) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Multi-line Comments — https://www.w3schools.com/php/php_comments_multiline.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Multi-line Comments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-constants
|
||||
title: "PHP Constants"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["define()", "const keyword", "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", "constants"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_constants.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Constants]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`define()` and `const` aren't interchangeable despite both creating constants — `define()` runs at RUNTIME (so it can live inside functions/conditionals, but never inside a class to define class constants), while `const` runs at COMPILE-TIME (so it must be top-level, but CAN define class constants), making the choice depend entirely on where in the code you need the constant. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Constant** — like a variable but immutable once defined; no `$` sign in the name. [S1]
|
||||
- **`define(NAME, value)`** — runtime constant creation; always global scope; usable inside functions/conditionals/loops; CANNOT define class constants. [S1]
|
||||
- **`const NAME = value;`** — compile-time constant creation; must be top-level (not inside functions/loops/if-else/try-catch); CAN define class constants; case-sensitive. [S1]
|
||||
- **Array constants** — both `define()` and `const` support array values. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- define() basic: `define("GREETING", "Welcome to W3Schools.com!"); echo GREETING;`. [S1]
|
||||
- define() inside a function still creates a global constant: `function myTest() { define("GREETING", "Welcome to W3Schools.com!"); } myTest(); echo GREETING; // accessible outside`. [S1]
|
||||
- const basic: `const GREETING = "Welcome to W3Schools.com!"; echo GREETING;`. [S1]
|
||||
- Array constants: `define("CARS", array("Volvo", "BMW", "Toyota")); echo CARS[0]; const ANIMALS = array("Cat", "Dog", "Horse"); echo ANIMALS[1];`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **define()과 const의 근본적 차이**: define()은 런타임에 실행되어 함수/조건문 내부에 선언 가능하지만 클래스 상수 정의 불가, const는 컴파일타임에 처리되어 최상위 스코프에서만 선언 가능하지만 클래스 상수 정의는 가능하다는 점이 명확히 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 함수 내부에서 define()으로 전역 상수를 선언하고 함수 밖에서 접근하는 패턴이 define()의 특이한 스코프 동작을 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
define() creates a global constant even when called inside a function (PHP):
|
||||
```php
|
||||
function myTest() {
|
||||
define("GREETING", "Welcome to W3Schools.com!");
|
||||
}
|
||||
myTest();
|
||||
echo GREETING; // accessible here, outside the function
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Magic Constants]], [[PHP OOP Constants]], [[PHP Variables]]
|
||||
- **참조 맥락:** 상수 정의 두 가지 방법 — 매직 상수(Magic Constants) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Constants — https://www.w3schools.com/php/php_constants.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Constants" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: php-cookies
|
||||
title: "PHP Cookies"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["setcookie()", "$_COOKIE", "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", "cookies"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_cookies.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Cookies]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`setcookie()` MUST run before any HTML output, including before the `<html>` tag — this is a hard requirement (not a style preference) because cookies are transmitted as part of the HTTP header, which must be sent before the response body; this is the same constraint sessions have. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Cookie** — a small text file the server stores in the browser, resent with every subsequent HTTP request. [S1]
|
||||
- **`setcookie(name, value, expire, path, domain, secure, httponly)`** — only `name` is required; all others optional. [S1]
|
||||
- **Must precede any output** — `setcookie()` must be called before `<html>` or any other output, since cookies are part of the HTTP header. [S1]
|
||||
- **`$_COOKIE`** — superglobal for reading cookie values. [S1]
|
||||
- **Deleting a cookie** — call `setcookie()` again with an expiration time in the PAST. [S1]
|
||||
- **Auto URL-encoding** — cookie values are automatically URL-encoded on send and decoded on receipt (use `setrawcookie()` to opt out). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create + retrieve: `setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); ... if(isset($_COOKIE[$cookie_name])) { echo $_COOKIE[$cookie_name]; }`. [S1]
|
||||
- Modify: re-calling `setcookie()` with a new value overwrites the old one. [S1]
|
||||
- Delete: `setcookie("username", "", time() - 3600); // expiration in the past`. [S1]
|
||||
- Check if cookies enabled: `setcookie("test_cookie", "test", time() + 3600, '/'); ... if(count($_COOKIE) > 0) { echo "Cookies are enabled."; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **출력 전 호출 필수**: setcookie()는 HTTP 헤더의 일부이므로 반드시 <html> 태그를 포함한 어떤 출력보다도 먼저 호출되어야 한다는 점이 두 번 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 30일 만료 쿠키로 사용자 이름을 저장하는 것이 로그인 상태 유지의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Creating and checking a cookie (PHP):
|
||||
```php
|
||||
<?php
|
||||
$cookie_name = "username";
|
||||
$cookie_value = "John Doe";
|
||||
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // must run before <html>
|
||||
?>
|
||||
<html>
|
||||
<body>
|
||||
<?php
|
||||
if (isset($_COOKIE[$cookie_name])) {
|
||||
echo "Value is: " . $_COOKIE[$cookie_name];
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP File Upload]], [[PHP Sessions]], [[PHP Superglobals]]
|
||||
- **참조 맥락:** 클라이언트 측 데이터 저장 — 세션(Sessions) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Cookies — https://www.w3schools.com/php/php_cookies.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Cookies" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: php-data-types
|
||||
title: "PHP Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["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", "data-types"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_datatypes.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A variable's data type can change automatically just by reassigning a different-typed value (`$x = 5;` then `$x = "Hello";` silently converts int→string) — this is distinct from CASTING, which changes the type WITHOUT changing the underlying value (`(string) $x` on `5` keeps it as "5", not a new value). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **8 core types** — string, int, float, bool, array, object, null, resource. [S1]
|
||||
- **`var_dump()`** — reveals type + value together. [S1]
|
||||
- **String** — a sequence of characters. [S1]
|
||||
- **Int** — non-decimal, -2,147,483,648 to 2,147,483,647; can be decimal/hex/octal/binary notation. [S1]
|
||||
- **Float** — a number with a decimal point or exponential form. [S1]
|
||||
- **Bool** — TRUE or FALSE, used in conditionals. [S1]
|
||||
- **Array** — multiple values in one variable. [S1]
|
||||
- **Object** — an instance of a programmer-defined class. [S1]
|
||||
- **NULL** — the special "no value" type; a variable created without a value defaults to NULL. [S1]
|
||||
- **Resource** — references an external resource (DB connection, file handle); advanced/rarely discussed directly. [S1]
|
||||
- **Dynamic typing vs. casting** — reassignment changes type automatically; explicit `(string)`/`(int)` casting changes type without altering the value's meaning. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Type inspection: `$x = 5; var_dump($x); // int(5)`. [S1]
|
||||
- Object example: `class Car { public $color; public $model; public function __construct($color, $model) { $this->color = $color; $this->model = $model; } } $myCar = new Car("red", "Volvo"); var_dump($myCar);`. [S1]
|
||||
- NULL assignment: `$x = "Hello world!"; $x = null; var_dump($x); // NULL`. [S1]
|
||||
- Automatic type change: `$x = 5; var_dump($x); $x = "Hello"; var_dump($x); // int then string`. [S1]
|
||||
- Explicit cast: `$x = 5; $x = (string) $x; var_dump($x); // string(1) "5"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 자동차 클래스 객체(Object)를 var_dump()로 검사하는 것이 데이터 타입 확인의 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Automatic type change vs. explicit casting (PHP):
|
||||
```php
|
||||
$x = 5;
|
||||
var_dump($x); // int(5)
|
||||
$x = "Hello";
|
||||
var_dump($x); // string (auto-changed by reassignment)
|
||||
|
||||
$x = 5;
|
||||
$x = (string) $x; // explicit cast, same value "5"
|
||||
var_dump($x);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Variables]], [[PHP Casting]], [[PHP Strings]], [[PHP OOP Classes Objects]]
|
||||
- **참조 맥락:** 데이터 타입 전체 개요 — 캐스팅(Casting)/클래스(OOP) 챕터로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Data Types — https://www.w3schools.com/php/php_datatypes.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-date
|
||||
title: "PHP Date"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["date()", "strtotime()", "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", "date", "time"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_date.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Date]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`strtotime()` accepts natural-language relative expressions like `"+2 weeks 4 days 2 hours 20 seconds"` or `"last Sunday"` and correctly parses them into Unix timestamps — but the source explicitly warns it "is not perfect," meaning arbitrary human phrasing should always be verified rather than trusted blindly. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`date(format, timestamp)`** — formats a timestamp (or "now" if omitted) into a readable string. [S1]
|
||||
- **Format characters** — `d`/`j` (day), `m` (month, 2-digit), `Y` (year, 4-digit), `l` (weekday name), `F` (month name), `H`/`h` (24/12-hour), `i` (minutes), `s` (seconds), `a` (am/pm). [S1]
|
||||
- **`date_default_timezone_set()` / `_get()`** — sets/reads the timezone used by all date/time functions in the script. [S1]
|
||||
- **`mktime(hour, minute, second, month, day, year)`** — returns the Unix timestamp for a specific date/time. [S1]
|
||||
- **`time()`** — current time as a Unix timestamp. [S1]
|
||||
- **`strtotime(datetime_string, basetimestamp)`** — parses an English textual date/time description into a Unix timestamp; supports relative expressions. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Multiple date formats: `echo date("Y/m/d"); echo date("Y.m.d"); echo date("Y-m-d"); echo date("l"); echo date('l, F j, Y');`. [S1]
|
||||
- Automatic copyright year: `© 2010-<?php echo date("Y");?>`. [S1]
|
||||
- Timezone-aware: `date_default_timezone_set("America/New_York"); echo date("Y-m-d H:i:s");`. [S1]
|
||||
- mktime for a specific historical date: `date_default_timezone_set("UTC"); $d = mktime(0, 0, 0, 10, 3, 1975); echo "October 3, 1975 was on a " . date("l", $d);`. [S1]
|
||||
- Relative date parsing: `$d = strtotime("+2 weeks 4 days 2 hours 20 seconds"); echo date("Y-m-d H:i:s", $d);`. [S1]
|
||||
- Iterative date generation (next 6 Saturdays): `$startdate = strtotime("Saturday"); $enddate = strtotime("+6 weeks", $startdate); while ($startdate < $enddate) { echo date("M d", $startdate) . "<br>"; $startdate = strtotime("+1 week", $startdate); }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **strtotime()의 불완전성 경고**: 자연어 날짜 문자열 파싱이 완벽하지 않으므로 입력 문자열을 항상 검증해야 한다는 팁이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 저작권 연도를 date("Y")로 자동 갱신하는 것이 웹사이트 실전 적용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Relative date parsing with strtotime() (PHP):
|
||||
```php
|
||||
$d = strtotime("+2 weeks 4 days 2 hours 20 seconds");
|
||||
echo "Date is " . date("Y-m-d H:i:s", $d);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Form Complete]], [[PHP Includes]]
|
||||
- **참조 맥락:** 날짜/시간 처리 — 파일 포함(Includes) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Date and Time — https://www.w3schools.com/php/php_date.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Date and Time" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: php-echo-print
|
||||
title: "PHP Echo Print"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["echo vs print", "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", "echo", "print"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_echo_print.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Echo Print]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`print` returns 1 (usable inside expressions) while `echo` returns nothing at all — this is the functional difference behind an otherwise near-identical pair of output statements, alongside echo accepting multiple comma-separated arguments where print accepts exactly one. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`echo`** — no return value; accepts multiple parameters; marginally faster than print. [S1]
|
||||
- **`print`** — returns 1 (usable in expressions); accepts only one argument. [S1]
|
||||
- **Both optional-parens** — `echo "x";` / `echo("x");` and `print "x";` / `print("x");` are equivalent. [S1]
|
||||
- **Double vs. single quotes** — double quotes allow direct variable interpolation (`"$txt"`); single quotes require concatenation (`'...' . $txt . '...'`). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- echo with multiple params: `echo "This ", "string ", "was ", "made ", "with multiple parameters.";`. [S1]
|
||||
- Double-quote interpolation: `echo "<h2>$txt1</h2>";`. [S1]
|
||||
- Single-quote concatenation: `echo '<h2>' . $txt1 . '</h2>';`. [S1]
|
||||
- print (single arg only): `print "Hello world!<br>";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **반환값 차이**: echo는 반환값이 없고, print는 1을 반환하여 표현식 내에서 사용 가능하다는 점이 핵심 차이로 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 여러 문자열을 콤마로 나열해 한 번에 출력하는 echo의 다중 인자 기능이 실전에서 자주 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
echo with multiple comma-separated arguments (PHP):
|
||||
```php
|
||||
echo "This ", "string ", "was ", "made ", "with multiple parameters.";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Variables]], [[PHP Data Types]], [[PHP String Concatenate]]
|
||||
- **참조 맥락:** 출력의 두 가지 방법 — 데이터 타입(Data Types) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP echo and print Functions — https://www.w3schools.com/php/php_echo_print.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP echo and print" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: php-error-handling
|
||||
title: "PHP Error Handling"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["set_error_handler", "trigger_error", "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", "error-handling"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_error_handling.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Error Handling]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`set_error_handler()` REPLACES PHP's built-in error handler for the rest of the script — meaning ANY error (even something as ordinary as referencing an undefined variable) routes through your custom function instead of the default warning, which is why the custom handler in the source catches `echo($test);` (an undefined-variable notice) just as easily as a triggered error. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`die()`** — simplest error handling: stop the script and print a message (e.g., after checking `file_exists()`). [S1]
|
||||
- **Custom error handler function** — accepts (error_level, error_message, [error_file, error_line, error_context]) — minimum 2, up to 5 parameters. [S1]
|
||||
- **Error report levels** — `E_WARNING` (2, non-fatal), `E_NOTICE` (8), `E_USER_ERROR` (256, fatal user-generated), `E_USER_WARNING` (512), `E_USER_NOTICE` (1024), `E_RECOVERABLE_ERROR` (4096), `E_ALL` (8191). [S1]
|
||||
- **`set_error_handler("functionName", errorLevel)`** — installs a custom handler, optionally scoped to a specific error level. [S1]
|
||||
- **`trigger_error($message, $level)`** — manually raises a custom error, useful for flagging invalid user input. [S1]
|
||||
- **`error_log()`** — sends error logs to a file, the server's system, or (with the mail-mode parameter) directly to an email address. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic die(): `if(!file_exists("welcome.txt")) { die("File not found"); } else { $file=fopen("welcome.txt","r"); }`. [S1]
|
||||
- Custom handler function: `function customError($errno, $errstr) { echo "<b>Error:</b> [$errno] $errstr<br>"; echo "Ending Script"; die(); }`. [S1]
|
||||
- Registering the handler: `set_error_handler("customError");`. [S1]
|
||||
- Triggering a custom error: `if ($test>=1) { trigger_error("Value must be 1 or below", E_USER_WARNING); }`. [S1]
|
||||
- Scoped handler (only E_USER_WARNING): `set_error_handler("customError", E_USER_WARNING);`. [S1]
|
||||
- Emailing an error log: `error_log("Error: [$errno] $errstr", 1, "someone@example.com", "From: webmaster@example.com");`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **커스텀 핸들러가 모든 에러를 가로챔**: 별도 에러 레벨을 지정하지 않으면 정의되지 않은 변수 참조 같은 사소한 것까지 모두 커스텀 핸들러로 라우팅된다는 점이 실험 예제로 검증됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 특정 에러 발생 시 웹마스터에게 이메일 알림을 보내는 것이 실전 모니터링의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Custom error handler scoped to a specific error level (PHP):
|
||||
```php
|
||||
function customError($errno, $errstr) {
|
||||
echo "<b>Error:</b> [$errno] $errstr<br>";
|
||||
echo "Ending Script";
|
||||
die();
|
||||
}
|
||||
set_error_handler("customError", E_USER_WARNING);
|
||||
$test = 2;
|
||||
if ($test >= 1) {
|
||||
trigger_error("Value must be 1 or below", E_USER_WARNING);
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Exceptions]], [[PHP Exception]], [[PHP File Open]]
|
||||
- **참조 맥락:** 절차적 에러 처리(die/custom handler/trigger_error) — 객체지향 예외 처리(Exception Handling) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Error Handling — https://www.w3schools.com/php/php_error_handling.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Error Handling" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: php-exception
|
||||
title: "PHP Exception"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["custom exception class", "re-throwing", "set_exception_handler", "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", "exceptions", "oop"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_exception.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Exception]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Re-throwing an exception requires nesting a `try` block INSIDE another `try` block — the inner try catches the raw system exception, then throws a new user-friendly `customException` in its own catch block, which the OUTER catch finally handles; this two-layer structure is how PHP lets you translate an internal error into a message safe to show end users. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Custom exception class** — must `extends Exception`; inherits `getLine()`, `getFile()`, `getMessage()`, and can add custom methods. [S1]
|
||||
- **Multiple exceptions** — a try block can have MULTIPLE catch blocks for different exception classes; PHP matches the first applicable one. [S1]
|
||||
- **Re-throwing** — nesting a try/catch inside another try, so a caught exception can be replaced with a different (often more user-friendly) one before reaching the outer catch. [S1]
|
||||
- **`set_exception_handler($functionName)`** — installs a top-level handler that catches ANY exception with no matching catch block anywhere. [S1]
|
||||
- **Core rule** — "If you throw something, you have to catch it" — every throw needs at least one corresponding catch (or a top-level handler as the ultimate fallback). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Custom exception class: `class customException extends Exception { public function errorMessage() { return 'Error on line '.$this->getLine().' in '.$this->getFile().': '.$this->getMessage().' is not a valid E-Mail address'; } }`. [S1]
|
||||
- Using it: `try { if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) { throw new customException($email); } } catch (customException $e) { echo $e->errorMessage(); }`. [S1]
|
||||
- Multiple catch blocks for different conditions: `try { if(...) { throw new customException($email); } if(strpos($email, "example") !== FALSE) { throw new Exception("$email is an example e-mail"); } } catch (customException $e) { ... } catch(Exception $e) { ... }`. [S1]
|
||||
- Re-throwing pattern: `try { try { if(strpos($email, "example") !== FALSE) { throw new Exception($email); } } catch(Exception $e) { throw new customException($email); } } catch (customException $e) { echo $e->errorMessage(); }`. [S1]
|
||||
- Top-level handler: `function myException($exception) { echo "Exception: " . $exception->getMessage(); } set_exception_handler('myException'); throw new Exception('Uncaught Exception occurred');`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **재발생(re-throw)의 이중 try 구조**: 원본 시스템 에러를 사용자 친화적 메시지로 바꾸려면 try 블록 안에 또 다른 try 블록을 중첩해야 한다는 구조적 필요성이 예제로 명확히 드러남. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이메일 형식 오류를 커스텀 예외 클래스로 감싸 사용자 친화적 메시지를 보여주는 것이 실전 예외 설계의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Re-throwing a system exception as a user-friendly custom exception (PHP):
|
||||
```php
|
||||
class customException extends Exception {
|
||||
public function errorMessage() {
|
||||
return $this->getMessage() . ' is not a valid E-Mail address.';
|
||||
}
|
||||
}
|
||||
try {
|
||||
try {
|
||||
if (strpos($email, "example") !== FALSE) {
|
||||
throw new Exception($email);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw new customException($email); // re-throw as friendlier exception
|
||||
}
|
||||
} catch (customException $e) {
|
||||
echo $e->errorMessage();
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Exceptions]], [[PHP Error Handling]], [[PHP OOP Inheritance]]
|
||||
- **참조 맥락:** 커스텀 예외 클래스와 상속 — OOP 섹션의 상속(Inheritance) 개념과 직접 연결됨.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Exception Handling — https://www.w3schools.com/php/php_exception.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Exception Handling" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: php-exceptions
|
||||
title: "PHP Exceptions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["try catch finally", "Exception object", "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", "exceptions", "try-catch"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_exceptions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Exceptions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An uncaught exception doesn't just print an error — it terminates the ENTIRE script, including any code AFTER the throwing line (`echo 'Hello';` never runs in the uncaught example) — making exception handling not just about nice error messages but about whether the rest of the program executes at all. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Exception** — an unwanted/unexpected event during script execution; thrown by many built-in functions/classes. [S1]
|
||||
- **`throw`** — raises an exception. [S1]
|
||||
- **`try`** — wraps code that might throw. [S1]
|
||||
- **`catch(Exception $e)`** — handles a thrown exception; specifies the exception type and a variable name. [S1]
|
||||
- **`finally`** — runs regardless of whether an exception was caught. [S1]
|
||||
- **`new Exception(message, code, previous)`** — all three constructor parameters optional. [S1]
|
||||
- **Exception object methods** — `getMessage()`, `getPrevious()`, `getCode()`, `getFile()`, `getLine()`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Uncaught exception halts everything after it: `echo divide(5, 0); echo 'Hello';` — "Hello" never prints, since the fatal error terminates the script. [S1]
|
||||
- Basic try/catch: `try { echo divide(5, 0); } catch(Exception $e) { echo 'Error: ' . $e->getMessage(); }`. [S1]
|
||||
- try/catch/finally: adds `finally { echo '<br>Process complete.'; }` which runs no matter what. [S1]
|
||||
- Full exception info: `catch(Exception $e) { $file = $e->getFile(); $line = $e->getLine(); $code = $e->getCode(); $message = $e->getMessage(); echo "Exception thrown in $file on line $line: [Code $code] $message"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **미처리 예외의 전체 중단 효과**: 예외가 처리되지 않으면 발생 지점 이후의 모든 코드가 실행되지 않고 스크립트 자체가 종료된다는 점이 예제로 직접 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — divide() 함수의 0으로 나누기 방지가 예외 처리의 표준 교육용 예시다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Try/catch/finally with full exception info (PHP):
|
||||
```php
|
||||
function divide($x, $y) {
|
||||
if ($y == 0) {
|
||||
throw new Exception("Cannot divide by zero.");
|
||||
}
|
||||
return $x / $y;
|
||||
}
|
||||
try {
|
||||
echo divide(5, 0);
|
||||
} catch (Exception $e) {
|
||||
echo "Exception in " . $e->getFile() . " on line " . $e->getLine() . ": " . $e->getMessage();
|
||||
} finally {
|
||||
echo '<br>Process complete.';
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP JSON]], [[PHP Error Handling]], [[PHP Exception]]
|
||||
- **참조 맥락:** 예외 처리 기초(throw/try/catch/finally) — 에러 처리(Error Handling) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Exceptions — https://www.w3schools.com/php/php_exceptions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Exceptions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: php-file
|
||||
title: "PHP File"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["readfile()", "PHP 파일 처리 개요"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "files"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_file.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP File]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source opens the file-handling chapter with an explicit warning about real damage — editing the wrong file, filling a hard drive with garbage data, or accidentally deleting content — framing file operations as genuinely risky rather than a routine data-manipulation task. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Core file functions** — `readfile()`, `fopen()`, `fread()`, `fgets()`, `fgetc()`, `feof()`, `fwrite()`, `fclose()`, `unlink()`. [S1]
|
||||
- **`readfile()`** — reads a file and writes it directly to the output buffer (typically the browser); simplest option when you just want to display file contents. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic readfile usage: `echo readfile("webdictionary.txt");`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **파일 조작의 위험성 경고**: 잘못된 파일 수정, 하드드라이브를 쓰레기 데이터로 채우는 것, 실수로 파일 내용 삭제 등 실질적 피해 가능성이 명시적으로 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 서버에 저장된 텍스트 파일(webdictionary.txt)을 읽어 브라우저에 바로 출력하는 것이 readfile()의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reading a file directly to output (PHP):
|
||||
```php
|
||||
echo readfile("webdictionary.txt");
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP File Open]], [[PHP File Create]], [[PHP File Upload]]
|
||||
- **참조 맥락:** 파일 처리 섹션의 도입부 — 열기/읽기/닫기(File Open) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP File Handling — https://www.w3schools.com/php/php_file.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP File Handling" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-file-create
|
||||
title: "PHP File Create"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fwrite()", "append mode", "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", "files", "fwrite"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_file_create.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP File Create]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP uses the SAME function (`fopen()`) to both open AND create files — passing `"w"` or `"a"` mode on a non-existent filename silently creates it, meaning there's no separate "create file" function; opening a file for writing IS how you create one. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`fopen($name, "w")` on a nonexistent file** — creates it. [S1]
|
||||
- **`fwrite($file, $string)`** — writes a string to an open file. [S1]
|
||||
- **`"w"` mode overwrites** — opening an EXISTING file in `"w"` mode ERASES all its content before writing new data. [S1]
|
||||
- **`"a"` mode appends** — preserves existing content, adds new data at the end. [S1]
|
||||
- **File permissions** — PHP must have write access to the target directory, or `fopen`/`fwrite` will fail. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create a new file: `$myfile = fopen("testfile.txt", "w")`. [S1]
|
||||
- Write multiple lines: `$myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); fwrite($myfile, "John Doe\n"); fwrite($myfile, "Jane Doe\n"); fclose($myfile);`. [S1]
|
||||
- Overwrite demonstration: opening the same "newfile.txt" again with `"w"` and writing different names ERASES "John Doe"/"Jane Doe" entirely, leaving only the new content. [S1]
|
||||
- Append demonstration: opening with `"a"` and writing adds new lines AFTER the existing content, without erasing anything. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **w 모드의 파괴적 동작**: 기존 파일을 "w" 모드로 열면 기존 데이터가 전부 삭제된다는 점이 이전/이후 내용 비교 예제로 직접 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 로그 파일에 새 항목을 추가할 때 "a" 모드를 사용하는 것이 append 모드의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Append mode preserves existing content (PHP):
|
||||
```php
|
||||
$myfile = fopen("newfile.txt", "a") or die("Unable to open file!");
|
||||
fwrite($myfile, "Donald Duck\n");
|
||||
fwrite($myfile, "Goofy Goof\n");
|
||||
fclose($myfile);
|
||||
// existing content is preserved; new lines added at the end
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP File Open]], [[PHP File Upload]]
|
||||
- **참조 맥락:** 파일 쓰기/덮어쓰기/추가 — 파일 업로드(File Upload) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP File Create/Write — https://www.w3schools.com/php/php_file_create.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP File Create/Write" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-file-open
|
||||
title: "PHP File Open"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fopen()", "fread()", "feof()", "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", "files", "fopen"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_file_open.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP File Open]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`feof()` is specifically designed for looping through data of UNKNOWN length — rather than counting lines in advance, `while(!feof($myfile)) { echo fgets($myfile); }` keeps reading exactly until the end-of-file marker is hit, making it the correct pattern for files whose size isn't known ahead of time. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`fopen(filename, mode)`** — opens a file; modes: `r` (read), `r+` (read/write, preserves data), `w` (write, erases existing), `w+` (read/write, erases), `a` (append), `a+` (append read/write), `x` (create-only, fails if exists), `x+` (create-only read/write). [S1]
|
||||
- **`fread($file, length)`** — reads up to `length` bytes; `filesize()` reads the whole file. [S1]
|
||||
- **`fclose($file)`** — closes an open file; good practice to always close after use to free server resources. [S1]
|
||||
- **`fgets($file)`** — reads one line; advances the file pointer to the next line after each call. [S1]
|
||||
- **`feof($file)`** — checks for end-of-file; useful for looping over data of unknown length. [S1]
|
||||
- **`fgetc($file)`** — reads one character; advances the pointer to the next character. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Open + read whole file: `$myfile = fopen("webdictionary.txt", "r") or die("Error: Unable to open file!"); echo fread($myfile, filesize("webdictionary.txt")); fclose($myfile);`. [S1]
|
||||
- Read one line: `$myfile = fopen("webdictionary.txt", "r") or die(...); echo fgets($myfile); fclose($myfile);`. [S1]
|
||||
- Loop until EOF (line by line): `while(!feof($myfile)) { echo fgets($myfile) . "<br>"; }`. [S1]
|
||||
- Loop until EOF (char by char): `while(!feof($myfile)) { echo fgetc($myfile); }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — feof()로 파일 끝까지 한 줄씩 읽어 출력하는 것이 알 수 없는 길이의 파일 처리 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reading a file line by line until EOF (PHP):
|
||||
```php
|
||||
$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
|
||||
while (!feof($myfile)) {
|
||||
echo fgets($myfile) . "<br>";
|
||||
}
|
||||
fclose($myfile);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP File]], [[PHP File Create]]
|
||||
- **참조 맥락:** 파일 열기/읽기/닫기 — 파일 생성/쓰기(File Create) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP File Open/Read/Close — https://www.w3schools.com/php/php_file_open.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP File Open/Read/Close" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: php-file-upload
|
||||
title: "PHP File Upload"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["$_FILES", "enctype multipart", "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", "files", "upload", "security"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_file_upload.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP File Upload]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Checking a file's extension alone is NOT proof it's a real image — the tutorial uses `getimagesize()` specifically to detect "fake images" (files renamed with an image extension but containing different content), showing that upload validation needs content-based checks, not just filename-based ones. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Required setup** — `file_uploads = On` in php.ini; HTML form must have `method="post"` AND `enctype="multipart/form-data"`. [S1]
|
||||
- **`$_FILES["fieldname"]`** — array holding uploaded file info: `["name"]`, `["tmp_name"]`, `["size"]`. [S1]
|
||||
- **`getimagesize()`** — detects whether an uploaded file is a genuine image (vs. a renamed fake). [S1]
|
||||
- **`file_exists()`** — checks for filename collisions before saving. [S1]
|
||||
- **`pathinfo($file, PATHINFO_EXTENSION)`** — extracts the file extension for type-checking. [S1]
|
||||
- **`move_uploaded_file($tmp_name, $target)`** — the final step that actually relocates the uploaded file from its temporary location to the destination. [S1]
|
||||
- **`$uploadOk` flag pattern** — accumulates validation failures across multiple checks (file exists, size limit, file type) before deciding whether to actually move the file. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Form requirements: `<form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="fileToUpload"> <input type="submit"> </form>`. [S1]
|
||||
- Real-image check: `$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; }`. [S1]
|
||||
- Size limit (500KB): `if ($_FILES["fileToUpload"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; }`. [S1]
|
||||
- Type whitelist: `if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { $uploadOk = 0; }`. [S1]
|
||||
- Final move: `if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "uploaded."; } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **확장자만으로는 불충분**: getimagesize()로 실제 이미지 콘텐츠인지 확인해야 하며, 확장자 이름만으로는 가짜 이미지를 걸러낼 수 없다는 점이 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 파일 존재 여부/크기/타입을 순차적으로 검사한 후 최종적으로 move_uploaded_file()로 이동하는 것이 안전한 업로드 처리의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Verifying the uploaded file is a genuine image (PHP):
|
||||
```php
|
||||
if (isset($_POST["submit"])) {
|
||||
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
|
||||
if ($check !== false) {
|
||||
echo "File is an image - " . $check["mime"] . ".";
|
||||
} else {
|
||||
echo "File is not an image.";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP File Create]], [[PHP Cookies]], [[PHP Filter]]
|
||||
- **참조 맥락:** 파일 처리 섹션의 마지막 — 쿠키(Cookies) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP File Upload — https://www.w3schools.com/php/php_file_upload.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP File Upload" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-filter
|
||||
title: "PHP Filter"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["filter_var", "validation vs sanitization", "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", "filter", "validation", "security"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_filter.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Filter]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`filter_var($int, FILTER_VALIDATE_INT)` has a subtle gotcha with the value `0` — because both a failed validation and a legitimate `0` result can look similar in a loose comparison, the source shows you must use the STRICT `=== false` check (or explicitly test for `=== 0`) rather than a truthy check, or valid zero values get wrongly flagged as invalid. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Validating vs. sanitizing** — validating checks if data is properly formed (doesn't change it); sanitizing removes illegal characters (may alter the data). [S1]
|
||||
- **`filter_var(var, filter, options)`** — applies one filter to one variable. [S1]
|
||||
- **`filter_input()`** — filters an external variable (e.g. from `$_GET`/`$_POST`) directly. [S1]
|
||||
- **`filter_var_array()`** — filters multiple variables at once. [S1]
|
||||
- **`filter_list()`** — enumerates all supported filter names/IDs. [S1]
|
||||
- **Validation filters** — `FILTER_VALIDATE_EMAIL`, `FILTER_VALIDATE_URL`, `FILTER_VALIDATE_INT`, `FILTER_VALIDATE_IP` — return `false` on invalid data, don't alter valid data. [S1]
|
||||
- **Sanitization filters** — `FILTER_SANITIZE_EMAIL`, `FILTER_SANITIZE_URL`, `FILTER_SANITIZE_NUMBER_INT` — strip illegal characters, may change the value. [S1]
|
||||
- **The "0" gotcha** — `FILTER_VALIDATE_INT` on `0` needs a strict `=== false`/`=== 0` check, not a simple truthy test. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Sanitize then validate email: `$email = filter_var($email, FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) { echo "valid"; }`. [S1]
|
||||
- Integer validation with the 0 gotcha fix: `if (filter_var($int, FILTER_VALIDATE_INT) === 0 || !filter_var($int, FILTER_VALIDATE_INT) === false) { echo "Integer is valid"; }`. [S1]
|
||||
- IP validation: `if (!filter_var($ip, FILTER_VALIDATE_IP) === false) { echo "$ip is a valid IP address"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **0 값 검증 함정**: FILTER_VALIDATE_INT로 0을 검증할 때 단순 진위 검사가 아니라 엄격한 === 비교가 필요하다는 점이 별도 팁으로 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이메일을 먼저 sanitize한 후 validate하는 2단계 처리가 안전한 입력 검증의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Sanitize then validate an email (PHP):
|
||||
```php
|
||||
$email = "john.doe@example.com";
|
||||
$email = filter_var($email, FILTER_SANITIZE_EMAIL); // remove illegal chars
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
|
||||
echo("$email is a valid email address");
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Sessions]], [[PHP Filter Advanced]], [[PHP Form Validation]]
|
||||
- **참조 맥락:** 입력 검증/정제 기초 — 고급 필터(Filter Advanced) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Filters — https://www.w3schools.com/php/php_filter.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Filters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-filter-advanced
|
||||
title: "PHP Filter Advanced"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["FILTER_FLAG_IPV6", "min_range", "PHP 고급 필터"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "filter", "validation"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_filter_advanced.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Filter Advanced]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`filter_var()`'s third parameter can be either a simple FLAG constant (`FILTER_FLAG_IPV6`) or a structured options array (`["options" => ["min_range" => 1, "max_range" => 200]]`) depending on the filter — meaning the function's signature flexes based on which filter you're using, requiring you to check each filter's specific option format rather than assuming one universal pattern. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Range validation** — `FILTER_VALIDATE_INT` with an `options` array specifying `min_range`/`max_range`. [S1]
|
||||
- **`FILTER_FLAG_IPV6`** — restricts `FILTER_VALIDATE_IP` to only accept IPv6-format addresses. [S1]
|
||||
- **`FILTER_FLAG_QUERY_REQUIRED`** — requires a URL to have a query string to pass `FILTER_VALIDATE_URL`. [S1]
|
||||
- **`FILTER_FLAG_STRIP_HIGH`** — combined with `FILTER_SANITIZE_STRING`, strips both HTML tags AND characters with ASCII value > 127 (non-ASCII characters). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Range-bounded integer: `filter_var($int, FILTER_VALIDATE_INT, array("options" => array("min_range"=>$min, "max_range"=>$max)));`. [S1]
|
||||
- IPv6 validation: `filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);`. [S1]
|
||||
- URL requiring a query string: `filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED);`. [S1]
|
||||
- Strip HTML + high-ASCII chars: `$str = "<h1>Hello WorldÆØÅ!</h1>"; $newstr = filter_var($str, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 1~200 범위 내 정수 검증이 나이/수량 등 범위 제한 입력 검증의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Validating an integer within a range (PHP):
|
||||
```php
|
||||
$int = 122; $min = 1; $max = 200;
|
||||
if (filter_var($int, FILTER_VALIDATE_INT, array("options" => array("min_range"=>$min, "max_range"=>$max))) === false) {
|
||||
echo("Variable value is not within the legal range");
|
||||
} else {
|
||||
echo("Variable value is within the legal range");
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Filter]], [[PHP Callback Functions]]
|
||||
- **참조 맥락:** 필터 옵션/플래그 심화 — 콜백 함수(Callback Functions) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Filters Advanced — https://www.w3schools.com/php/php_filter_advanced.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Filters Advanced" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-form-complete
|
||||
title: "PHP Form Complete"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["sticky forms", "PHP 폼 완성 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "forms", "validation"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_form_complete.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Form Complete]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Radio buttons are "re-checked" differently from text fields after submission — text inputs echo into the `value` attribute (`value="<?php echo $name;?>"`), but radio buttons instead conditionally echo the literal word `"checked"` into the tag based on which value matches, since a radio's persisted state is a boolean attribute, not a value string. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Sticky form pattern** — preserving submitted values in the form after validation errors, so the user doesn't have to re-type everything. [S1]
|
||||
- **Text inputs** — echo the variable into the `value` attribute. [S1]
|
||||
- **Textarea** — echo the variable BETWEEN the opening/closing tags (no `value` attribute exists for textarea). [S1]
|
||||
- **Radio buttons** — conditionally echo the literal string `"checked"` based on an `isset()` + equality check against the submitted gender. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Text input sticky value: `<input type="text" name="name" value="<?php echo $name;?>">`. [S1]
|
||||
- Textarea sticky value: `<textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>`. [S1]
|
||||
- Radio button sticky check: `<input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 검증 실패 후에도 입력값을 유지하는 sticky form 패턴이 사용자 경험 개선의 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Preserving a radio button's checked state after submission (PHP):
|
||||
```php
|
||||
<input type="radio" name="gender"
|
||||
<?php if (isset($gender) && $gender=="female") echo "checked";?>
|
||||
value="female">Female
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Form URL Email]], [[PHP Date]]
|
||||
- **참조 맥락:** 폼 검증 섹션의 마무리 — 날짜(Date) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Complete Form Example — https://www.w3schools.com/php/php_form_complete.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Complete Form Example" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: php-form-required
|
||||
title: "PHP Form Required"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["empty()", "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", "forms", "validation", "required"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_form_required.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Form Required]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The pattern for making a field "required" is a mirrored if/else: `empty($_POST["field"])` sets an ERROR message and leaves the display variable untouched, while the else branch runs the field through `test_input()` — meaning error state and sanitized value live in two separate variables that are only ever set on opposite branches of the same check. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`empty($_POST["field"])`** — checks if a field was left blank. [S1]
|
||||
- **Error variables** — `$nameErr`, `$emailErr`, `$genderErr`, `$websiteErr` — hold per-field error messages, initialized empty. [S1]
|
||||
- **Required vs. optional handling** — required fields set an error message when empty; optional fields just stay empty (no error) when blank. [S1]
|
||||
- **Displaying errors inline** — `<span class="error"><?php echo $nameErr;?></span>` placed next to each field. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Required field check: `if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); }`. [S1]
|
||||
- Optional field (no error): `if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); }`. [S1]
|
||||
- Inline error display: `Name: <input type="text" name="name"> <span class="error">* <?php echo $nameErr;?></span>`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 필수 필드(이름/이메일/성별)와 선택 필드(웹사이트/코멘트)를 다르게 처리하는 것이 실전 폼 검증의 표준 구조다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Required-field validation with error message (PHP):
|
||||
```php
|
||||
if (empty($_POST["name"])) {
|
||||
$nameErr = "Name is required";
|
||||
} else {
|
||||
$name = test_input($_POST["name"]);
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Form Validation]], [[PHP Form URL Email]]
|
||||
- **참조 맥락:** 필수 필드 검증 — 이메일/URL 형식 검증(URL Email) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Forms - Required Fields — https://www.w3schools.com/php/php_form_required.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Forms - Required Fields" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: php-form-url-email
|
||||
title: "PHP Form URL Email"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["filter_var", "FILTER_VALIDATE_EMAIL", "PHP 이메일/URL 검증"]
|
||||
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", "forms", "validation", "email", "url"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_form_url_email.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Form URL Email]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Email validation uses a dedicated built-in filter (`filter_var($email, FILTER_VALIDATE_EMAIL)`), explicitly called "the easiest and safest way," while name and URL validation both rely on hand-written regex patterns (`preg_match`) — meaning PHP's philosophy is to prefer built-in validators when they exist and fall back to regex only when no dedicated filter is available. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Name validation via regex** — `preg_match("/^[a-zA-Z-' ]*$/", $name)` — allows only letters, dashes, apostrophes, whitespace. [S1]
|
||||
- **Email validation via `filter_var()`** — `filter_var($email, FILTER_VALIDATE_EMAIL)` — the recommended, safest approach (not regex). [S1]
|
||||
- **URL validation via regex** — a complex pattern matching `http://`, `https://`, `ftp://`, or `www.` prefixes. [S1]
|
||||
- **`preg_match()` return semantics** — true if the pattern matches, false otherwise; combined with `!` to detect INVALID input. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Name check: `if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; }`. [S1]
|
||||
- Email check: `if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; }`. [S1]
|
||||
- URL check: `if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **이메일 검증 방식의 명확한 권장**: 이메일은 정규표현식이 아니라 filter_var()가 "가장 쉽고 안전한 방법"으로 명시적으로 권장됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — filter_var()로 이메일 형식을 검증하는 것이 정규표현식보다 안전한 표준 방법으로 제시된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Email validation via filter_var(), the recommended approach (PHP):
|
||||
```php
|
||||
$email = test_input($_POST["email"]);
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$emailErr = "Invalid email format";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Form Required]], [[PHP RegEx]], [[PHP Form Complete]]
|
||||
- **참조 맥락:** 이메일/URL 형식 검증 — 완성된 폼 예제(Complete) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Forms - Validate E-mail and URL — https://www.w3schools.com/php/php_form_url_email.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Forms - Validate E-mail and URL" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-form-validation
|
||||
title: "PHP Form Validation"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP_SELF exploit", "XSS", "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", "forms", "security", "xss"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_form_validation.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Form Validation]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`$_SERVER["PHP_SELF"]` used raw in a form's `action` attribute is a genuine XSS vulnerability — a crafted URL like `test_form.php/"><script>alert('hacked')</script>` gets echoed verbatim into the HTML, injecting a live script tag; wrapping it in `htmlspecialchars()` converts the dangerous characters to harmless HTML entities, neutralizing the exploit. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`$_SERVER["PHP_SELF"]`** — returns the current script's filename; often used as a self-submitting form's `action`. [S1]
|
||||
- **PHP_SELF XSS vulnerability** — appending a crafted path suffix to the URL lets an attacker inject a `<script>` tag into the raw output. [S1]
|
||||
- **`htmlspecialchars()`** — the fix: converts `<`, `>`, `"` etc. into HTML entities, neutralizing injected markup. [S1]
|
||||
- **`trim()`** — strips extraneous whitespace/tabs/newlines from user input. [S1]
|
||||
- **`stripslashes()`** — removes backslashes from user input. [S1]
|
||||
- **`test_input()`** — a custom reusable function combining trim + stripslashes + htmlspecialchars, applied to every `$_POST` field. [S1]
|
||||
- **`$_SERVER["REQUEST_METHOD"] == "POST"`** — gate that skips validation when the form hasn't been submitted yet. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Exploit demonstration: raw `$_SERVER["PHP_SELF"]` in a form action, combined with a URL like `.../test_form.php/%22%3E%3Cscript%3Ealert('hacked')%3C/script%3E`, results in an executable injected script. [S1]
|
||||
- Fix: `<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">`. [S1]
|
||||
- Sanitizing function: `function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; }`. [S1]
|
||||
- Full validation gate: `if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = test_input($_POST["name"]); ... }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **PHP_SELF의 실질적 보안 취약점**: htmlspecialchars() 없이 사용하면 XSS 공격에 노출된다는 점이 구체적인 공격 예제로 직접 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — test_input() 함수로 모든 $_POST 필드를 일괄 정제하는 패턴이 실전 폼 검증의 표준이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reusable input sanitization function (PHP):
|
||||
```php
|
||||
function test_input($data) {
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
$data = htmlspecialchars($data);
|
||||
return $data;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Forms]], [[PHP Form Required]], [[PHP Superglobals Server]]
|
||||
- **참조 맥락:** 보안을 고려한 폼 처리 — 필수 필드 검증(Required) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Form Validation — https://www.w3schools.com/php/php_form_validation.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Form Validation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-forms
|
||||
title: "PHP Forms"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["GET vs POST", "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", "forms", "get", "post"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_forms.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Forms]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
GET data is visible in the URL and bookmarkable, but capped at ~2000 characters and NEVER safe for passwords — while POST data is invisible in the URL (no bookmarking) but has no size limit and supports file uploads — meaning the "developer preference for POST" isn't arbitrary, it directly follows from these visibility/size/capability trade-offs. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`$_GET` / `$_POST`** — superglobal arrays collecting form data by the `name` attribute as key. [S1]
|
||||
- **GET** — data visible in URL; ~2000 character limit; bookmarkable; NEVER use for passwords/sensitive data. [S1]
|
||||
- **POST** — data invisible (embedded in request body); no size limit; supports file uploads (multi-part binary). [S1]
|
||||
- **No validation shown yet** — this chapter demonstrates the mechanics only; security/validation comes in later chapters. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- POST form: `<form action="welcome.php" method="post"> Name: <input type="text" name="name"><br> ...`. [S1]
|
||||
- Retrieval: `echo $_POST["name"]; echo $_POST["email"];`. [S1]
|
||||
- GET form equivalent: `<form action="welcome_get.php" method="get"> ...` retrieved via `$_GET["name"]`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **GET의 보안 경고**: 비밀번호 등 민감한 정보는 절대 GET으로 전송해서는 안 된다는 점이 강하게 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 챕터의 예제는 검증 없는 기초 폼 처리이며, 다음 챕터부터 보안을 고려한 검증이 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic POST form and retrieval (PHP/HTML):
|
||||
```html
|
||||
<form action="welcome.php" method="post">
|
||||
Name: <input type="text" name="name"><br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
```
|
||||
```php
|
||||
echo $_POST["name"];
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Superglobals Get]], [[PHP Superglobals Post]], [[PHP Form Validation]]
|
||||
- **참조 맥락:** 폼 처리의 기초 — 보안을 고려한 폼 검증(Form Validation) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Form Handling — https://www.w3schools.com/php/php_forms.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Form Handling" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: php-functions
|
||||
title: "PHP Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["variadic functions", "strict_types", "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", "functions"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `...` variadic operator can ONLY be the LAST parameter — putting it first (`function myFamily(...$firstname, $lastname)`) is explicitly shown as an ERROR case, because a variadic parameter greedily collects all remaining arguments into an array, leaving nothing for any parameter declared after it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **1000+ built-in functions** available directly. [S1]
|
||||
- **User-defined function** — `function name($params) { ...; return $value; }`; not case-sensitive; not auto-run (must be called). [S1]
|
||||
- **Default parameter values** — `function setHeight($height = 50) {...}` — used when the argument is omitted. [S1]
|
||||
- **Pass by reference** — `function add_five(&$value) { $value += 5; }` — the `&` makes changes persist back to the caller's variable (default is pass-by-value, a copy). [S1]
|
||||
- **Variadic functions (`...`)** — `function sumMyNumbers(...$x) {...}` — accepts an unknown number of arguments, collected into an array; must be the LAST parameter. [S1]
|
||||
- **Loosely typed by default** — no type declarations required. [S1]
|
||||
- **`declare(strict_types=1);`** (PHP 7+) — must be the FIRST line of the file; enforces strict type checking, throwing a Fatal Error on type mismatch. [S1]
|
||||
- **Return type declarations** — `function addNumbers(float $a, float $b) : float {...}` — colon syntax before the opening brace. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Default parameter: `function setHeight($height = 50) { echo "The height is : $height <br>"; } setHeight(350); setHeight(); // uses default 50`. [S1]
|
||||
- Pass by reference: `function add_five(&$value) { $value += 5; } $num = 2; add_five($num); echo $num; // 7`. [S1]
|
||||
- Variadic (valid, last position): `function sumMyNumbers(...$x) { $n = 0; $len = count($x); for($i = 0; $i < $len; $i++) { $n += $x[$i]; } return $n; }`. [S1]
|
||||
- Variadic (invalid, first position — errors): `function myFamily(...$firstname, $lastname) {...} // error: variadic must be last`. [S1]
|
||||
- Strict types: `<?php declare(strict_types=1); function addNumbers(int $a, int $b) { return $a + $b; } echo addNumbers(5, "5 days"); // Fatal Error — "5 days" is not an int`. [S1]
|
||||
- Return type declaration: `function addNumbers(float $a, float $b) : float { return $a + $b; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **가변 인자의 위치 제약**: ... 연산자를 사용하는 매개변수는 반드시 마지막에 위치해야 하며, 그렇지 않으면 에러가 발생한다는 점이 실패 예제로 직접 검증됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 개수가 정해지지 않은 숫자들의 합을 구하는 가변 인자 함수(sumMyNumbers)가 실전 활용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Variadic function summing an unknown number of arguments (PHP):
|
||||
```php
|
||||
function sumMyNumbers(...$x) {
|
||||
$n = 0;
|
||||
$len = count($x);
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$n += $x[$i];
|
||||
}
|
||||
return $n;
|
||||
}
|
||||
$a = sumMyNumbers(5, 2, 6, 2, 7, 7);
|
||||
echo $a;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Arrays]], [[PHP OOP Classes Objects]], [[PHP Callback Functions]]
|
||||
- **참조 맥락:** 함수 정의/호출의 전체 문법 — 배열(Arrays) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Functions — https://www.w3schools.com/php/php_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: php-if-else
|
||||
title: "PHP If Else"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["if statement", "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", "conditions", "if"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_if_else.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP If Else]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP names four distinct conditional statement forms upfront (if / if-else / if-elseif-else / switch) as one family, framing them as increasingly powerful tools for the same underlying task — selecting which code runs — rather than teaching `if` in isolation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`if (condition) { ... }`** — runs a code block only when the condition is true. [S1]
|
||||
- **Four conditional forms overview** — if, if...else, if...elseif...else, switch — each handles a different number of branches. [S1]
|
||||
- **Braces required for blocks** — the code to run sits inside `{ }`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Literal comparison: `if (5 > 3) { echo "Have a good day!"; }`. [S1]
|
||||
- Variable comparison: `$t = 14; if ($t < 20) { echo "Have a good day!"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 조건문 4종 세트의 첫 단계로, 비교 연산자(If Operators) 챕터로 바로 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic if with a variable condition (PHP):
|
||||
```php
|
||||
$t = 14;
|
||||
if ($t < 20) {
|
||||
echo "Have a good day!";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Operators]], [[PHP If Operators]], [[PHP If Else If]], [[PHP Switch]]
|
||||
- **참조 맥락:** 조건문의 출발점 — 비교/논리 연산자(If Operators) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP if Statements — https://www.w3schools.com/php/php_if_else.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP if Statements" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-if-else-if
|
||||
title: "PHP If Else If"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["elseif", "PHP if-else-if"]
|
||||
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", "conditions", "elseif"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_if_else_if.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP If Else If]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP's time-of-day example uses `date("H")` returning a STRING that's then compared against string literals like `"20"` and `"10"` — the comparisons `$t < "20"` still work correctly via PHP's loose typing (numeric string comparison), showing PHP doesn't require explicit numeric conversion for this common pattern. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`if...else`** — two-branch conditional: true-block vs. false-block. [S1]
|
||||
- **`if...elseif...else`** — multi-branch conditional: multiple sequential conditions plus a catch-all `else`. [S1]
|
||||
- **`elseif`** — single keyword (not `else if`) in PHP syntax. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- if...else: `$t = date("H"); if ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; }`. [S1]
|
||||
- if...elseif...else: `if ($t < "10") { echo "Have a good morning!"; } elseif ($t < "20") { echo "Have a good day!"; } else { echo "Have a good night!"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 시간대별 인사말(아침/낮/밤) 분기가 elseif 체인의 대표적 실전 예시다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Three-way time-of-day branch with elseif (PHP):
|
||||
```php
|
||||
$t = date("H");
|
||||
if ($t < "10") {
|
||||
echo "Have a good morning!";
|
||||
} elseif ($t < "20") {
|
||||
echo "Have a good day!";
|
||||
} else {
|
||||
echo "Have a good night!";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP If Operators]], [[PHP If Shorthand]], [[PHP Date]]
|
||||
- **참조 맥락:** 다중 분기 조건문 — 축약형(Shorthand If) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP if...else Statements — https://www.w3schools.com/php/php_if_else_if.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP if...else Statements" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: php-if-nested
|
||||
title: "PHP If Nested"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP 중첩 조건문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.86
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "conditions", "nested-if"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_if_nested.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP If Nested]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The inner if/else in a nested-if structure only executes at all once the outer condition passes — the example's inner check (`$a > 20`) never even evaluates unless `$a > 10` is already true, meaning the nested structure encodes "check this second thing, but only if the first thing already held." [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Nested if** — placing an if statement inside another if statement's block. [S1]
|
||||
- **Conditional evaluation** — the inner if only runs when the outer condition is satisfied. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Nested structure: `$a = 13; if ($a > 10) { echo "Above 10"; if ($a > 20) { echo " and also above 20"; } else { echo " but not above 20"; } }` — outputs "Above 10 but not above 20". [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 값이 특정 구간(10 초과, 20 초과)에 속하는지 단계적으로 검사하는 것이 중첩 조건문의 대표 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Nested if with inner else (PHP):
|
||||
```php
|
||||
$a = 13;
|
||||
if ($a > 10) {
|
||||
echo "Above 10";
|
||||
if ($a > 20) {
|
||||
echo " and also above 20";
|
||||
} else {
|
||||
echo " but not above 20";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP If Shorthand]], [[PHP Switch]]
|
||||
- **참조 맥락:** 조건문 섹션의 마지막 단계형 — 스위치(Switch) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Nested if Statements — https://www.w3schools.com/php/php_if_nested.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Nested if Statements" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-if-operators
|
||||
title: "PHP If Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["comparison operators in if", "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", "conditions", "operators"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_if_operators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP If Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A single if-condition can chain arbitrarily many OR comparisons against the same variable (`$a == 2 || $a == 3 || $a == 4 || ...`) — the source demonstrates this as a legitimate (if verbose) pattern for checking membership in a small fixed set of values, foreshadowing why switch/match exist as more concise alternatives. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Comparison operators in if** — `==`, `===`, `!=`, `<>`, `!==`, `>`, `<`, `>=`, `<=`. [S1]
|
||||
- **Logical operators in if** — `and`/`&&`, `or`/`||`, `xor`, `!`. [S1]
|
||||
- **Chaining multiple comparisons** — arbitrarily many conditions can be combined with `||`/`&&` in one if statement. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Equality check: `$t = 14; if ($t == 14) { echo "Have a good day!"; }`. [S1]
|
||||
- AND combination: `$a = 200; $b = 33; $c = 500; if ($a > $b && $a < $c) { echo "Both conditions are true"; }`. [S1]
|
||||
- Chained OR (membership check): `$a = 5; if ($a == 2 || $a == 3 || $a == 4 || $a == 5 || $a == 6 || $a == 7) { echo "$a is a number between 2 and 7"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 여러 OR 조건을 체이닝해 특정 값 집합에 속하는지 확인하는 패턴이 나중에 switch/match로 대체될 동기를 제공한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Chained OR comparisons for a value-set membership check (PHP):
|
||||
```php
|
||||
$a = 5;
|
||||
if ($a == 2 || $a == 3 || $a == 4 || $a == 5 || $a == 6 || $a == 7) {
|
||||
echo "$a is a number between 2 and 7";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP If Else]], [[PHP Operators]], [[PHP If Else If]], [[PHP Switch]]
|
||||
- **참조 맥락:** 비교/논리 연산자를 조건문에 적용 — if...else 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP if Operators — https://www.w3schools.com/php/php_if_operators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP if Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: php-if-shorthand
|
||||
title: "PHP If Shorthand"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["ternary operator", "PHP 축약 조건문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "conditions", "ternary"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_if_shorthand.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP If Shorthand]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The one-line `if` (without braces or else) and the ternary `if...else` shorthand are TWO DIFFERENT techniques with different syntax — the former just omits braces for a single statement (`if ($a < 10) $b = "Hello";`), while the latter is the `?:` ternary/conditional-expression form (`$b = $a < 10 ? "Hello" : "Good Bye";`), and they aren't interchangeable. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **One-line if** — braces can be omitted for a single statement: `if (condition) statement;`. [S1]
|
||||
- **Ternary operator (`?:`)** — the shorthand for if...else: `$result = condition ? valueIfTrue : valueIfFalse;`. [S1]
|
||||
- **Also called** — "Ternary Operators" or "Conditional Expressions." [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- One-line if: `$a = 5; if ($a < 10) $b = "Hello"; echo $b;`. [S1]
|
||||
- Ternary if...else: `$a = 13; $b = $a < 10 ? "Hello" : "Good Bye"; echo $b;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 짧은 이진 분기를 한 줄로 표현하는 삼항 연산자가 실전 코드에서 자주 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Ternary operator as if...else shorthand (PHP):
|
||||
```php
|
||||
$a = 13;
|
||||
$b = $a < 10 ? "Hello" : "Good Bye";
|
||||
echo $b;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP If Else If]], [[PHP If Nested]], [[PHP Operators]]
|
||||
- **참조 맥락:** 조건문의 축약형 — 중첩 조건문(Nested If) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Shorthand if Statements — https://www.w3schools.com/php/php_if_shorthand.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Shorthand if Statements" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-includes
|
||||
title: "PHP Includes"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["include vs require", "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", "include", "require"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_includes.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Includes]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`include` and `require` behave identically on SUCCESS but diverge sharply on FAILURE — a missing file only produces a warning with `include` (script continues, later code still runs), while the same missing file with `require` triggers a fatal error that halts script execution entirely, making the choice a statement about how critical that file is to the page working at all. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`include 'file';`** / **`require 'file';`** — insert a file's content into the calling file. [S1]
|
||||
- **Failure behavior difference** — `include` → `E_WARNING`, script continues; `require` → `E_ERROR` (fatal), script stops. [S1]
|
||||
- **When to use `include`** — non-critical files like headers, footers, navigation menus (page can still render without them). [S1]
|
||||
- **When to use `require`** — critical files like configuration or database connections (page is meaningless without them). [S1]
|
||||
- **Included files share variable scope** — variables defined in an included file become usable in the calling file. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Include a footer: `<?php include 'footer.php';?>`. [S1]
|
||||
- Include a nav menu: `<div class="menu"><?php include 'menu.php';?></div>`. [S1]
|
||||
- Include shares variables: `vars.php` defines `$color='red'; $car='BMW';`; the including file can then `echo "I have a $color $car.";` after `include 'vars.php';`. [S1]
|
||||
- include on missing file (continues): `<?php include 'noFileExists.php'; echo "I have a $color $car."; ?>` — the echo still runs (with warning), though `$color`/`$car` are undefined here since the file wasn't found. [S1]
|
||||
- require on missing file (halts): `<?php require 'noFileExists.php'; echo "I have a $color $car."; ?>` — the echo NEVER executes; script dies at the require line. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **실패 시 동작의 근본적 차이**: include는 경고만 내고 스크립트가 계속 실행되지만, require는 치명적 에러를 내고 스크립트 실행이 완전히 중단된다는 점이 대비 예제로 직접 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 모든 페이지가 공유하는 표준 헤더/푸터/메뉴 파일을 include로 재사용하는 것이 실전 코드 재사용의 대표 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
require halts execution on failure, unlike include (PHP):
|
||||
```php
|
||||
<?php require 'noFileExists.php'; // fatal error — script dies here
|
||||
echo "This line never runs.";
|
||||
?>
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Date]], [[PHP Files]], [[PHP Variables Scope]]
|
||||
- **참조 맥락:** 코드 재사용을 위한 파일 포함 — 파일 처리(Files) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Include Files — https://www.w3schools.com/php/php_includes.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Include Files" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: php-install
|
||||
title: "PHP Install"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP Installation", "PHP 설치"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "installation"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_install.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Install]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Most developers never need to "install" PHP at all — if a web host already supports it, dropping `.php` files into the web directory is sufficient, since the server parses them automatically; manual installation is only needed when running your own web server. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Two setup paths** — use a web host with existing PHP support (no setup needed), or install a web server + PHP + database (e.g. MySQL) yourself. [S1]
|
||||
- **`phpversion()`** — function to check the installed PHP version. [S1]
|
||||
- **Official resource** — php.net has installation instructions for self-hosted setups. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Check version: `echo phpversion();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — phpversion()으로 서버 환경의 PHP 버전을 확인하는 것이 실전에서 자주 쓰이는 진단 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Checking the installed PHP version (PHP):
|
||||
```php
|
||||
echo phpversion();
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Intro]], [[PHP Syntax]]
|
||||
- **참조 맥락:** 실행 환경 준비 — 문법(Syntax) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Installation — https://www.w3schools.com/php/php_install.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Installation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: php-intro
|
||||
title: "PHP Intro"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["What is PHP", "PHP 소개"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "intro"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_intro.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP is explicitly framed as server-executed — code runs on the server and only the resulting HTML reaches the browser, meaning PHP source is never visible to the client, unlike JavaScript which ships as readable source to the browser. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **PHP** — "PHP: Hypertext Preprocessor"; a widely-used, open source, server-side scripting language. [S1]
|
||||
- **Server-side execution** — PHP scripts run on the server; the result is returned to the browser as HTML. [S1]
|
||||
- **Platform/server compatibility** — runs on Windows/Linux/Unix/Mac; works with Nginx/Apache/IIS/Cloudflare. [S1]
|
||||
- **Database support** — MySQL, PostgreSQL, MS SQL, DB2, Oracle, MongoDB, etc. [S1]
|
||||
- **`.php` file extension** — files can mix text, HTML, CSS, JavaScript, and PHP code. [S1]
|
||||
- **PHP 8 highlights** — JIT compiler, Union Types, Named Arguments, Match Expressions, Nullsafe Operator (`?->`), Attributes, new functions (`str_contains()`, etc.). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- What PHP can do: generate dynamic content, manage files, collect form data, handle cookies, modify databases, control access, encrypt data, output non-HTML formats (images, PDF, XML). [S1]
|
||||
- Prerequisite knowledge: HTML, CSS, JavaScript basics recommended before starting PHP. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대형 블로그 시스템과 소셜 네트워크가 PHP 기반으로 운영된다는 점이 언급된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
해당 챕터는 개념 소개 중심으로 별도 코드 예제가 없음 — 다음 챕터([[PHP Install]])에서 실행 환경 설정이 시작된다.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Install]], [[PHP Syntax]]
|
||||
- **참조 맥락:** PHP 튜토리얼의 도입부 — 설치/문법 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Introduction — https://www.w3schools.com/php/php_intro.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Introduction" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-iterables
|
||||
title: "PHP Iterables"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Iterator interface", "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", "iterables", "iterator"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_iterables.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Iterables]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `iterable` type hint accepts EITHER a plain array OR any object implementing the `Iterator` interface — meaning a function declared `function printIterable(iterable $x)` works identically whether called with `["a","b","c"]` or a custom `MyIterator` object, since both satisfy the same "can be foreach'd" contract. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`iterable`** (PHP 7.1+) — a pseudo-type usable as a function parameter or return type; means "anything loopable with foreach." [S1]
|
||||
- **Two things satisfy `iterable`** — any array, or any object implementing the `Iterator` interface. [S1]
|
||||
- **`Iterator` interface — 5 required methods** — `current()` (return current element), `key()` (return current key — int/float/bool/string only), `next()` (advance pointer), `rewind()` (reset pointer to start), `valid()` (false if pointer is past the end). [S1]
|
||||
- **Custom iterator pattern** — implement all 5 methods manually to make any custom class loopable via foreach. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Iterable parameter accepting both array and iterator object: `function printIterable(iterable $x) { foreach($x as $item) { echo $item; } } printIterable(["a", "b", "c"]); $iterator = new ArrayIterator(["d", "e", "f"]); printIterable($iterator);`. [S1]
|
||||
- Iterable return type: `function getIterable():iterable { return ["a", "b", "c"]; } foreach(getIterable() as $item) { echo $item; }`. [S1]
|
||||
- Custom Iterator implementation: `class MyIterator implements Iterator { private $items = []; private $pointer = 0; public function __construct($items) { $this->items = array_values($items); } public function current() { return $this->items[$this->pointer]; } public function key() { return $this->pointer; } public function next() { $this->pointer++; } public function rewind() { $this->pointer = 0; } public function valid() { return $this->pointer < count($this->items); } }`. [S1]
|
||||
- Using the custom iterator as an iterable: `$iterator = new MyIterator(["a", "b", "c"]); printIterable($iterator);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 배열과 커스텀 이터레이터 객체를 동일한 함수에 전달할 수 있는 것이 iterable 타입 힌트의 실전 가치다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A function accepting both an array and an Iterator object via iterable (PHP):
|
||||
```php
|
||||
function printIterable(iterable $x) {
|
||||
foreach ($x as $item) {
|
||||
echo $item;
|
||||
}
|
||||
}
|
||||
printIterable(["a", "b", "c"]); // array works
|
||||
printIterable(new ArrayIterator(["d", "e", "f"])); // Iterator object works too
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Namespaces]], [[PHP MySQL Intro]], [[PHP Looping Foreach]]
|
||||
- **참조 맥락:** 언어 핵심 문법의 마지막 챕터 — MySQL 연동 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Iterables — https://www.w3schools.com/php/php_iterables.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Iterables" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-json
|
||||
title: "PHP JSON"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["json_encode", "json_decode", "PHP JSON"]
|
||||
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", "json"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_json.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP JSON]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`json_decode()` returns a PHP OBJECT by default — accessed via `->property` syntax — but passing `true` as the second argument switches it to an ASSOCIATIVE ARRAY instead, accessed via `["key"]` syntax, meaning the exact same JSON string can be decoded into two structurally different PHP representations depending on one boolean flag. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`json_encode($value)`** — converts a PHP value (array/object) to a JSON string. [S1]
|
||||
- **`json_decode($jsonString)`** — converts JSON into a PHP object by default. [S1]
|
||||
- **`json_decode($jsonString, true)`** — the second `true` argument decodes into an associative array instead. [S1]
|
||||
- **Associative array → JSON object** — `array("Peter"=>35, ...)` encodes to a JSON object `{"Peter":35,...}`. [S1]
|
||||
- **Indexed array → JSON array** — `array("Volvo", "BMW", "Toyota")` encodes to a JSON array `["Volvo","BMW","Toyota"]`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Encode associative array (→ JSON object): `$age = array("Peter"=>35, "Ben"=>37, "Joe"=>43); echo json_encode($age);`. [S1]
|
||||
- Encode indexed array (→ JSON array): `$cars = array("Volvo", "BMW", "Toyota"); echo json_encode($cars);`. [S1]
|
||||
- Decode to object (default): `$jsonobj = '{"Peter":35,"Ben":37,"Joe":43}'; $obj = json_decode($jsonobj); echo $obj->Peter;`. [S1]
|
||||
- Decode to associative array (with `true`): `$arr = json_decode($jsonobj, true); echo $arr["Peter"];`. [S1]
|
||||
- Loop through decoded object: `foreach($obj as $key => $value) { echo $key . " => " . $value . "<br>"; }`. [S1]
|
||||
- Loop through decoded associative array: same `foreach ($arr as $key => $value)` pattern works identically. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **디코딩 결과 타입의 이중성**: json_decode()는 기본적으로 객체를 반환하지만, 두 번째 인자로 true를 주면 연관 배열로 반환된다는 점이 핵심 차이로 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 나이 데이터를 JSON으로 인코딩/디코딩하고 foreach로 순회하는 것이 API 데이터 교환의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Decoding JSON to an associative array vs. object (PHP):
|
||||
```php
|
||||
$jsonobj = '{"Peter":35,"Ben":37,"Joe":43}';
|
||||
$obj = json_decode($jsonobj); // object: $obj->Peter
|
||||
$arr = json_decode($jsonobj, true); // associative array: $arr["Peter"]
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Callback Functions]], [[PHP Arrays Associative]], [[PHP Exceptions]]
|
||||
- **참조 맥락:** JSON 인코딩/디코딩 — 예외 처리(Exceptions & Errors) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP and JSON — https://www.w3schools.com/php/php_json.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP and JSON" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: php-looping
|
||||
title: "PHP Looping"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP 반복문 개요"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "loops"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_looping.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Looping]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP names four loop types up front (while, do...while, for, foreach) and frames each around a distinct question — "as long as true" (while), "at least once, then as long as true" (do...while), "a fixed count" (for), "for every array element" (foreach) — setting up each subsequent chapter as the answer to a specific looping scenario rather than presenting `for` as a universal default. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`while`** — loops as long as a condition is true (condition checked first). [S1]
|
||||
- **`do...while`** — runs once, then repeats as long as the condition is true (condition checked after). [S1]
|
||||
- **`for`** — loops a specified/known number of times. [S1]
|
||||
- **`foreach`** — loops over each element of an array. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 챕터는 4가지 반복문 유형의 개요만 제공하며, 세부 문법은 각각의 후속 챕터에서 다룬다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 반복문 선택 기준(조건 기반 vs 횟수 기반 vs 배열 순회)의 개념적 도입부다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
해당 챕터는 개념 소개 중심으로 별도 코드 예제가 없음 — 다음 챕터([[PHP Looping While]])에서 while 루프 실습이 시작된다.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Looping While]], [[PHP Looping For]], [[PHP Looping Foreach]]
|
||||
- **참조 맥락:** 반복문 4종의 개념적 도입부 — while 루프 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Loops — https://www.w3schools.com/php/php_looping.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Loops" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-looping-break
|
||||
title: "PHP Looping Break"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["break statement", "PHP break"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "loops", "break"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_looping_break.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Looping Break]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`break` works identically across ALL four PHP loop types (for, while, do-while, foreach) — this chapter's entire purpose is to demonstrate that one keyword's behavior (immediately end the entire loop) generalizes uniformly regardless of which loop construct wraps it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`break`** — immediately ends the entire loop's execution, regardless of loop type. [S1]
|
||||
- **Applies uniformly to** — for, while, do...while, foreach. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- For: `for ($x = 0; $x < 10; $x++) { if ($x == 4) { break; } echo "The number is: $x <br>"; }`. [S1]
|
||||
- While: `$x = 0; while($x < 10) { if ($x == 4) { break; } echo "The number is: $x <br>"; $x++; }`. [S1]
|
||||
- Do-while: `$i = 1; do { if ($i == 3) break; echo $i; $i++; } while ($i < 6);`. [S1]
|
||||
- Foreach: `foreach ($colors as $value) { if ($value == "blue") break; echo "$value<br>"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 4가지 반복문 모두에서 동일하게 동작하는 break의 범용성이 핵심이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
break behaves identically across loop types (PHP):
|
||||
```php
|
||||
for ($x = 0; $x < 10; $x++) {
|
||||
if ($x == 4) { break; }
|
||||
echo "The number is: $x <br>";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Looping Foreach]], [[PHP Looping Continue]], [[PHP Functions]]
|
||||
- **참조 맥락:** 모든 반복문 공통의 break 동작 — continue 챕터와 짝을 이룸.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Break Statement — https://www.w3schools.com/php/php_looping_break.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Break Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-looping-continue
|
||||
title: "PHP Looping Continue"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["continue statement", "PHP continue"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "loops", "continue"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_looping_continue.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Looping Continue]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Like `break`, `continue` behaves identically across all four loop types (for, while, do-while, foreach) — this chapter mirrors the break chapter's structure exactly, reinforcing that PHP's loop-control keywords are orthogonal to which loop construct they're used in. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`continue`** — skips the rest of the current iteration and proceeds to the next one, without ending the whole loop. [S1]
|
||||
- **Applies uniformly to** — for, while, do...while, foreach. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- For: `for ($x = 0; $x < 10; $x++) { if ($x == 4) { continue; } echo "The number is: $x <br>"; }`. [S1]
|
||||
- While: `$x = 0; while($x < 10) { if ($x == 4) { continue; } echo "The number is: $x <br>"; $x++; }`. [S1]
|
||||
- Do-while: `$i = 0; do { $i++; if ($i == 3) continue; echo $i; } while ($i < 6);`. [S1]
|
||||
- Foreach: `foreach ($colors as $value) { if ($value == "blue") continue; echo "$value<br>"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 특정 조건의 반복만 건너뛰고 나머지는 계속 진행하는 필터링 패턴이 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
continue skips only the current iteration (PHP):
|
||||
```php
|
||||
foreach ($colors as $value) {
|
||||
if ($value == "blue") continue;
|
||||
echo "$value<br>";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Looping Break]], [[PHP Functions]]
|
||||
- **참조 맥락:** 반복문 섹션의 마지막 — 함수(Functions) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Continue Statement — https://www.w3schools.com/php/php_looping_continue.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Continue Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: php-looping-do-while
|
||||
title: "PHP Looping Do While"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["do while loop", "PHP do-while 반복문"]
|
||||
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", "loops", "do-while"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_looping_do_while.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Looping Do While]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The source deliberately shows the SAME do...while loop run twice — once with `$i = 1` (condition true from the start) and once with `$i = 8` (condition false from the start) — to prove the loop still executes once in both cases, since the condition is checked AFTER the body runs, not before. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`do { ... } while (condition);`** — the condition is tested AFTER the code runs, guaranteeing at least one execution. [S1]
|
||||
- **`break`** / **`continue`** — work the same as in while loops. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Condition true from start: `$i = 1; do { echo $i; $i++; } while ($i < 6);` — runs normally. [S1]
|
||||
- Condition false from start (still runs once): `$i = 8; do { echo $i; $i++; } while ($i < 6);` — prints 8, then stops (condition already false). [S1]
|
||||
- Break: `$i = 1; do { if ($i == 3) break; echo $i; $i++; } while ($i < 6);`. [S1]
|
||||
- Continue: `$i = 0; do { $i++; if ($i == 3) continue; echo $i; } while ($i < 6);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **최소 1회 실행 보장**: $i=8로 시작해 조건이 처음부터 거짓이어도 do...while은 최소 한 번은 실행된다는 점이 두 가지 예제 비교로 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 조건이 거짓이어도 최소 1회 실행이 필요한 상황(메뉴 표시 등)에 사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Do-while runs once even with a false-from-start condition (PHP):
|
||||
```php
|
||||
$i = 8;
|
||||
do {
|
||||
echo $i; // prints 8
|
||||
$i++;
|
||||
} while ($i < 6); // condition already false, but body already ran once
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Looping While]], [[PHP Looping For]]
|
||||
- **참조 맥락:** while 루프와의 실행 시점 차이 — for 루프 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP do while Loop — https://www.w3schools.com/php/php_looping_do_while.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP do while Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-looping-for
|
||||
title: "PHP Looping For"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["for loop", "PHP for 반복문"]
|
||||
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", "loops", "for"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_looping_for.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Looping For]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `for` loop's three clauses each run at a different time relative to the loop body — initialization runs ONCE before anything, the condition runs BEFORE each iteration, and the increment runs AFTER each iteration — meaning changing the increment direction (`$x++` to `$x--`) alone, combined with a matching condition, is all that's needed to count backwards instead of forwards. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`for (init; condition; increment) { ... }`** — init runs once; condition checked before each iteration; increment runs after each iteration. [S1]
|
||||
- **Use case** — when the number of iterations is known ahead of time. [S1]
|
||||
- **Counting down** — reversing the increment (`$x--`) and flipping the condition (`$x >= 0`). [S1]
|
||||
- **`break`** / **`continue`** — work the same as other loop types. [S1]
|
||||
- **Custom step size** — `$x += 10` for stepping by 10 instead of 1. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Counting up: `for ($x = 0; $x <= 10; $x++) { echo "The number is: $x <br>"; }`. [S1]
|
||||
- Counting down: `for ($x = 10; $x >= 0; $x--) { echo "The number is: $x <br>"; }`. [S1]
|
||||
- Break: `for ($x = 0; $x <= 10; $x++) { if ($x == 3) break; echo "The number is: $x <br>"; }`. [S1]
|
||||
- Continue: `for ($x = 0; $x <= 10; $x++) { if ($x == 3) continue; echo "The number is: $x <br>"; }`. [S1]
|
||||
- Step 10: `for ($x = 0; $x <= 100; $x += 10) { echo "The number is: $x <br>"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 10부터 0까지 카운트다운하는 예제가 증감 방향 조정의 대표 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Counting down with a for loop (PHP):
|
||||
```php
|
||||
for ($x = 10; $x >= 0; $x--) {
|
||||
echo "The number is: $x <br>";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Looping Do While]], [[PHP Looping Foreach]], [[PHP Looping Break]]
|
||||
- **참조 맥락:** 반복 횟수를 아는 경우의 표준 반복문 — foreach 루프 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP for Loop — https://www.w3schools.com/php/php_looping_for.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP for Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-looping-foreach
|
||||
title: "PHP Looping Foreach"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["foreach loop", "byref", "PHP foreach 반복문"]
|
||||
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", "loops", "foreach", "arrays"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_looping_foreach.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Looping Foreach]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
By default, modifying the loop variable inside `foreach` does NOT affect the original array — but adding a single `&` (`foreach ($colors as &$x)`) switches to by-reference assignment, meaning changes to `$x` inside the loop DO mutate `$colors` directly, a one-character difference with a completely different mutation contract. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`foreach ($array as $value)`** — loops over indexed array values. [S1]
|
||||
- **`foreach ($array as $key => $value)`** — loops over associative arrays, exposing both key and value. [S1]
|
||||
- **Works on objects too** — iterates over public properties (`$name => $value`). [S1]
|
||||
- **By-value default** — modifying the loop variable does not change the source array. [S1]
|
||||
- **By-reference (`&$x`)** — modifying the loop variable DOES change the source array. [S1]
|
||||
- **`break`** / **`continue`** — same semantics as other loops. [S1]
|
||||
- **Alternative syntax** — `foreach (...) : ... endforeach;`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Indexed array: `$colors = array("red", "green", "blue", "yellow"); foreach ($colors as $value) { echo "$value <br>"; }`. [S1]
|
||||
- Associative array: `$members = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43"); foreach ($members as $key => $value) { echo "$key : $value <br>"; }`. [S1]
|
||||
- Object properties: `foreach ($myCar as $x => $y) { echo "$x: $y <br>"; }`. [S1]
|
||||
- By-value (no mutation): `foreach ($colors as $x) { if ($x == "blue") $x = "pink"; } // $colors unchanged`. [S1]
|
||||
- By-reference (mutates original): `foreach ($colors as &$x) { if ($x == "blue") $x = "pink"; } // $colors now has "pink" instead of "blue"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **참조 전달의 예외적 동작**: 기본적으로 반복 변수 수정은 원본 배열에 영향을 주지 않지만, &를 붙이면 원본이 실제로 변경된다는 점이 두 예제로 명확히 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 배열 값을 순회하며 특정 조건에 따라 원본을 직접 수정해야 할 때 &$x 참조 전달이 사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
By-reference foreach mutates the original array (PHP):
|
||||
```php
|
||||
$colors = array("red", "green", "blue", "yellow");
|
||||
foreach ($colors as &$x) {
|
||||
if ($x == "blue") $x = "pink";
|
||||
}
|
||||
var_dump($colors); // "blue" is now "pink" in the original array
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Looping For]], [[PHP Arrays]], [[PHP OOP Classes Objects]]
|
||||
- **참조 맥락:** 배열/객체 순회 전용 반복문 — break/continue 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP foreach Loop — https://www.w3schools.com/php/php_looping_foreach.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP foreach Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-looping-while
|
||||
title: "PHP Looping While"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["while loop", "endwhile", "PHP while 반복문"]
|
||||
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", "loops", "while"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_looping_while.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Looping While]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP's while loop supports an alternative colon-based syntax (`while ($i < 6): ... endwhile;`) purely for template/HTML-embedding contexts — functionally identical to the brace syntax, but this "alt syntax" pattern (also seen in if/foreach) exists specifically because it reads more cleanly when PHP is interleaved with HTML markup. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`while (condition) { ... }`** — condition checked BEFORE each iteration; false-from-start means zero executions. [S1]
|
||||
- **`break`** — exits the loop early even if the condition is still true. [S1]
|
||||
- **`continue`** — skips the rest of the current iteration, proceeds to the next condition check. [S1]
|
||||
- **Alternative syntax** — `while (condition): ... endwhile;` — same behavior, colon-based. [S1]
|
||||
- **Custom step size** — incrementing by more than 1 per iteration (e.g. `$i += 10`). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic loop: `$i = 1; while ($i < 6) { echo $i; $i++; }`. [S1]
|
||||
- Break: `$i = 1; while ($i < 6) { if ($i == 3) break; echo $i; $i++; }`. [S1]
|
||||
- Continue: `$i = 0; while ($i < 6) { $i++; if ($i == 3) continue; echo $i; }`. [S1]
|
||||
- Alt syntax: `$i = 1; while ($i < 6): echo $i; $i++; endwhile;`. [S1]
|
||||
- Step-10 counting: `$i = 0; while ($i < 100) { $i += 10; echo $i . "<br>"; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 카운터를 10씩 증가시켜 100까지 세는 예제가 스텝 크기 조정의 대표 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
While loop with alternative colon syntax (PHP):
|
||||
```php
|
||||
$i = 1;
|
||||
while ($i < 6):
|
||||
echo $i;
|
||||
$i++;
|
||||
endwhile;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Looping]], [[PHP Looping Do While]], [[PHP Looping Break]], [[PHP Looping Continue]]
|
||||
- **참조 맥락:** 조건 기반 반복의 기본형 — do-while과의 실행 시점 차이가 다음 챕터의 핵심.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP while Loop — https://www.w3schools.com/php/php_looping_while.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP while Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-magic-constants
|
||||
title: "PHP Magic Constants"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["__LINE__", "__FILE__", "PHP 매직 상수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "magic-constants"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_magic_constants.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Magic Constants]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Magic constants are the opposite of normal constants — instead of holding a fixed value defined once, each one dynamically CHANGES based on where in the code it's evaluated (`__LINE__` differs on every line, `__FUNCTION__` differs per function), making them contextual metadata rather than stored values. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Magic constants** — 9 predefined constants whose value depends on where they're used, providing script-state info (file, line, class, function, namespace). [S1]
|
||||
- **Naming convention** — start and end with double underscores `__`, except `ClassName::class`. [S1]
|
||||
- **Not case-sensitive** — `__LINE__` and `__line__` are equivalent. [S1]
|
||||
- **The 9 constants** — `__CLASS__`, `__DIR__`, `__FILE__`, `__FUNCTION__`, `__LINE__`, `__METHOD__`, `__NAMESPACE__`, `__TRAIT__`, `ClassName::class`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- `__CLASS__` — class name if used inside a class. [S1]
|
||||
- `__DIR__` — directory of the current file. [S1]
|
||||
- `__FILE__` — full path + filename. [S1]
|
||||
- `__FUNCTION__` — current function name. [S1]
|
||||
- `__LINE__` — current line number. [S1]
|
||||
- `__METHOD__` — class name + function name combined. [S1]
|
||||
- `__NAMESPACE__` — current namespace name. [S1]
|
||||
- `__TRAIT__` — current trait name. [S1]
|
||||
- `ClassName::class` — fully qualified class name including namespace. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — __LINE__/__FILE__은 디버깅/로깅 시 에러 위치를 정확히 기록하는 데 자주 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Magic constants reflect their context (PHP):
|
||||
```php
|
||||
echo __LINE__; // current line number
|
||||
echo __FILE__; // full path of this file
|
||||
echo __FUNCTION__; // name of the enclosing function
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Constants]], [[PHP Operators]], [[PHP OOP Classes Objects]]
|
||||
- **참조 맥락:** 문맥 의존적 상수 — 연산자(Operators) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Magic Constants — https://www.w3schools.com/php/php_magic_constants.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Magic Constants" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -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).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-math
|
||||
title: "PHP Math"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["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", "math"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_math.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Math]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`rand()` accepts optional min/max parameters that fundamentally change its behavior — bare `rand()` returns an arbitrary-range random number, while `rand(10, 100)` constrains the result to an inclusive range, making the two-argument form the one actually usable for bounded scenarios like dice rolls or ID generation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`pi()`** — returns the value of π. [S1]
|
||||
- **`min()` / `max()`** — lowest/highest value among a list of arguments. [S1]
|
||||
- **`abs()`** — absolute (positive) value. [S1]
|
||||
- **`sqrt()`** — square root. [S1]
|
||||
- **`round()`** — rounds a float to the nearest integer. [S1]
|
||||
- **`rand()`** — random number; optional `(min, max)` params bound the range (inclusive). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Pi: `echo(pi());`. [S1]
|
||||
- Min/max: `echo(min(0, 150, -8, -200)); echo(max(0, 150, -8, -200));`. [S1]
|
||||
- Absolute value: `echo(abs(-6.7)); // 6.7`. [S1]
|
||||
- Square root: `echo(sqrt(64)); // 8`. [S1]
|
||||
- Rounding: `echo(round(3.60)); echo(round(0.49));`. [S1]
|
||||
- Bounded random: `echo(rand(10, 100)); // between 10 and 100 inclusive`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — rand(10, 100)처럼 범위 지정 난수 생성이 게임/추첨 등 실전에서 자주 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Bounded random integer (PHP):
|
||||
```php
|
||||
echo(rand(10, 100)); // random integer between 10 and 100 inclusive
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Numbers]], [[PHP Casting]], [[PHP Constants]]
|
||||
- **참조 맥락:** 수학 함수 모음 — 상수(Constants) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Math Functions — https://www.w3schools.com/php/php_math.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Math Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-mysql-connect
|
||||
title: "PHP MySQL Connect"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["MySQLi vs PDO", "PHP MySQL 연결"]
|
||||
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", "mysql", "mysqli", "pdo"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_connect.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Connect]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Switching database systems later is trivial with PDO (change the connection string + a few queries) but requires rewriting EVERYTHING with MySQLi (queries included) — since PDO works across 12 different database systems while MySQLi only works with MySQL, the choice between them is really a bet on whether the project will ever need to migrate databases. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **MySQLi (MySQL Improved)** — works only with MySQL; offers both object-oriented AND procedural APIs. [S1]
|
||||
- **PDO (PHP Data Objects)** — works across 12 different database systems; object-oriented only. [S1]
|
||||
- **Both support Prepared Statements** — critical for protecting against SQL injection. [S1]
|
||||
- **Connection requires 4 pieces** — server name, username, password, database name. [S1]
|
||||
- **PDO's exception-based error handling** — `PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION` — throws exceptions on query problems, caught via `catch(PDOException $e)`. [S1]
|
||||
- **Closing connections** — automatic at script end; can be forced early via `$conn->close()` (MySQLi OOP), `mysqli_close($conn)` (procedural), or `$conn = null;` (PDO). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- MySQLi OOP connection: `$conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }`. [S1]
|
||||
- MySQLi procedural connection: `$conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { die("Connection failed: " . mysqli_connect_error()); }`. [S1]
|
||||
- PDO connection: `try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **DB 전환 용이성의 차이**: PDO는 다른 DB로 전환 시 연결 문자열과 일부 쿼리만 수정하면 되지만, MySQLi는 쿼리를 포함한 전체 코드를 다시 작성해야 한다는 점이 명확히 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — PDO의 예외 기반 에러 처리(ERRMODE_EXCEPTION)가 데이터베이스 연결 문제를 안전하게 다루는 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
PDO connection with exception-based error handling (PHP):
|
||||
```php
|
||||
try {
|
||||
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
echo "Connected successfully";
|
||||
} catch (PDOException $e) {
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Intro]], [[PHP MySQL Create DB]], [[PHP Exception]]
|
||||
- **참조 맥락:** MySQLi/PDO 연결 방식 — 데이터베이스 생성(Create DB) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Connect to MySQL — https://www.w3schools.com/php/php_mysql_connect.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Connect to MySQL" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-mysql-create-db
|
||||
title: "PHP MySQL Create DB"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["CREATE DATABASE", "PHP MySQL DB 생성"]
|
||||
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", "mysql", "database"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_create.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Create DB]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Connecting to CREATE a database omits the database-name argument entirely — `new mysqli($servername, $username, $password)` has only 3 arguments, unlike the 4-argument connection used everywhere else, since the database you're about to create doesn't exist yet to connect to. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`CREATE DATABASE dbname`** — the SQL command to create a database. [S1]
|
||||
- **3-argument connection for creation** — no database name yet, since it doesn't exist. [S1]
|
||||
- **Requires admin privileges** — creating/deleting databases needs administrative access. [S1]
|
||||
- **`$conn->query($sql)`** (MySQLi OOP) — executes the CREATE DATABASE statement, returns `true` on success. [S1]
|
||||
- **`$conn->exec($sql)`** (PDO) — the PDO equivalent for executing a non-SELECT statement. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- MySQLi OOP: `$conn = new mysqli($servername, $username, $password); $sql = "CREATE DATABASE myDB"; if ($conn->query($sql) === TRUE) { echo "Database created successfully"; } else { echo "Error creating database: " . $conn->error; }`. [S1]
|
||||
- MySQLi procedural: `$conn = mysqli_connect($servername, $username, $password); if (mysqli_query($conn, $sql)) { echo "Database created successfully"; }`. [S1]
|
||||
- PDO: `$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); ... $conn->exec($sql); echo "Database created successfully";` — wrapped in try/catch(PDOException). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 특별히 없으나, DB 생성 시 연결 인자가 3개뿐이라는 점이 다른 모든 챕터의 4개 인자 패턴과 유일하게 다름. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — myDB라는 이름의 데이터베이스를 생성하는 것이 이후 테이블 생성 챕터의 전제 조건이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Creating a database with only 3 connection arguments (PHP):
|
||||
```php
|
||||
$conn = new mysqli($servername, $username, $password); // no dbname yet
|
||||
$sql = "CREATE DATABASE myDB";
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo "Database created successfully";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Connect]], [[PHP MySQL Create Table]]
|
||||
- **참조 맥락:** 데이터베이스 생성 — 테이블 생성(Create Table) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Create a MySQL Database — https://www.w3schools.com/php/php_mysql_create.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Create a MySQL Database" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-mysql-create-table
|
||||
title: "PHP MySQL Create Table"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["CREATE TABLE", "AUTO_INCREMENT", "PHP MySQL 테이블 생성"]
|
||||
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", "mysql", "create-table"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_create_table.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Create Table]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `reg_date` column's default value (`DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP`) does double duty — it auto-fills on INSERT and auto-refreshes on every UPDATE, meaning a single column definition handles both "record creation time" and "last modified time" without any PHP-side logic. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`CREATE TABLE`** — the SQL command; this chapter creates "MyGuests" with 5 columns. [S1]
|
||||
- **Column attributes** — `UNSIGNED` (positive numbers + zero only), `AUTO_INCREMENT` (auto-increases by 1 per new record), `PRIMARY KEY` (uniquely identifies rows, often paired with AUTO_INCREMENT), `NOT NULL` (value required), `DEFAULT value` (fallback when none is provided). [S1]
|
||||
- **Every table needs a primary key** — a unique-per-record identifier column. [S1]
|
||||
- **Requires create privileges** — a separate permission from admin privileges (used for CREATE DATABASE). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full table definition: `CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP )`. [S1]
|
||||
- Executed via MySQLi OOP: `$conn->query($sql)`; procedural: `mysqli_query($conn, $sql)`; PDO: `$conn->exec($sql)` inside try/catch. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — reg_date 컬럼이 생성 시각과 수정 시각을 동시에 자동 관리하는 것이 실전 스키마 설계의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Column with dual-purpose auto-updating timestamp (SQL):
|
||||
```sql
|
||||
CREATE TABLE MyGuests (
|
||||
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
firstname VARCHAR(30) NOT NULL,
|
||||
lastname VARCHAR(30) NOT NULL,
|
||||
email VARCHAR(50),
|
||||
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Create DB]], [[PHP MySQL Insert]], [[SQL Create Table]]
|
||||
- **참조 맥락:** 테이블 스키마 정의 — 데이터 삽입(Insert) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Create Table — https://www.w3schools.com/php/php_mysql_create_table.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Create Table" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: php-mysql-delete
|
||||
title: "PHP MySQL Delete"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["DELETE FROM", "PHP MySQL 삭제"]
|
||||
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", "mysql", "delete"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_delete.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Delete]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Omitting the `WHERE` clause in a `DELETE` statement deletes EVERY record in the table — the source flags this with an explicit "NOTE" warning, since `DELETE FROM MyGuests` (without `WHERE id=3`) would wipe the entire table rather than doing nothing or erroring. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`DELETE FROM table WHERE condition`** — removes matching records. [S1]
|
||||
- **WHERE is what limits the blast radius** — omitting it deletes ALL records in the table. [S1]
|
||||
- **Executed like other write operations** — `$conn->query($sql)` (MySQLi OOP), `mysqli_query($conn, $sql)` (procedural), `$conn->exec($sql)` (PDO). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Delete by ID: `$sql = "DELETE FROM MyGuests WHERE id=3"; if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; } else { echo "Error deleting record: " . $conn->error; }`. [S1]
|
||||
- PDO equivalent: `$sql = "DELETE FROM MyGuests WHERE id=3"; $conn->exec($sql); echo "Record deleted successfully";` wrapped in try/catch(PDOException). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **WHERE 절 생략의 파괴적 결과**: WHERE 절을 생략하면 테이블의 모든 레코드가 삭제된다는 점이 명시적 경고(NOTE)로 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — id=3 게스트 레코드만 삭제하는 것이 안전한 조건부 삭제의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Deleting a specific record, never omitting WHERE (SQL/PHP):
|
||||
```php
|
||||
$sql = "DELETE FROM MyGuests WHERE id=3"; // WHERE is mandatory to avoid deleting everything
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo "Record deleted successfully";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Select Order By]], [[PHP MySQL Update]]
|
||||
- **참조 맥락:** 레코드 삭제 — 레코드 수정(Update) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Delete Data — https://www.w3schools.com/php/php_mysql_delete.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Delete Data" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: php-mysql-insert
|
||||
title: "PHP MySQL Insert"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["INSERT INTO", "PHP MySQL 데이터 삽입"]
|
||||
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", "mysql", "insert"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_insert.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Insert]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
AUTO_INCREMENT and default-timestamp columns must be OMITTED from the INSERT statement entirely — the `id` and `reg_date` columns aren't listed in `INSERT INTO MyGuests (firstname, lastname, email)` at all, since MySQL fills them in automatically; explicitly specifying them would defeat their automatic behavior. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`INSERT INTO table (columns) VALUES (values)`** — adds a new record. [S1]
|
||||
- **Quoting rules** — the whole SQL query is quoted in PHP; string values inside are quoted; numeric values are NOT quoted; `NULL` is never quoted. [S1]
|
||||
- **AUTO_INCREMENT/default-timestamp columns are omitted** — `id` and `reg_date` don't appear in the column list at all; MySQL fills them automatically. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Insert statement omitting auto-managed columns: `$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com')";`. [S1]
|
||||
- MySQLi OOP execution: `if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; }`. [S1]
|
||||
- PDO execution: `$conn->exec($sql); echo "New record created successfully";` wrapped in try/catch(PDOException). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **자동 관리 컬럼 생략 규칙**: AUTO_INCREMENT나 기본 타임스탬프를 가진 컬럼은 INSERT 문에 명시하지 않아야 MySQL이 자동으로 값을 채운다는 점이 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — MyGuests 테이블에 이름/이메일만 삽입하고 id/reg_date는 자동 처리되는 것이 실전 삽입 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Inserting a record while omitting auto-managed columns (PHP):
|
||||
```php
|
||||
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
|
||||
VALUES ('John', 'Doe', 'john@example.com')"; // id, reg_date auto-filled
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo "New record created successfully";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Create Table]], [[PHP MySQL Insert Last ID]], [[PHP MySQL Insert Multiple]]
|
||||
- **참조 맥락:** 데이터 삽입 기초 — 마지막 삽입 ID 조회(Insert Last ID) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Insert Data — https://www.w3schools.com/php/php_mysql_insert.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Insert Data" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-mysql-insert-last-id
|
||||
title: "PHP MySQL Insert Last ID"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["insert_id", "lastInsertId", "PHP MySQL 마지막 ID"]
|
||||
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", "mysql", "insert", "auto-increment"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_insert_lastid.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Insert Last ID]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Retrieving the auto-generated ID uses three completely different syntax forms across the three connection APIs — `$conn->insert_id` (MySQLi OOP property), `mysqli_insert_id($conn)` (MySQLi procedural function), and `$conn->lastInsertId()` (PDO method) — meaning the same conceptual operation has zero syntax overlap between APIs. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`$conn->insert_id`** (MySQLi OOP) — property holding the last AUTO_INCREMENT value generated. [S1]
|
||||
- **`mysqli_insert_id($conn)`** (MySQLi procedural) — the equivalent function form. [S1]
|
||||
- **`$conn->lastInsertId()`** (PDO) — the equivalent method form. [S1]
|
||||
- **Only meaningful after INSERT/UPDATE on an AUTO_INCREMENT field** — retrieves the ID assigned during that specific operation. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- MySQLi OOP: `if ($conn->query($sql) === TRUE) { $last_id = $conn->insert_id; echo "Last inserted ID is: " . $last_id; }`. [S1]
|
||||
- MySQLi procedural: `if (mysqli_query($conn, $sql)) { $last_id = mysqli_insert_id($conn); echo "Last inserted ID is: " . $last_id; }`. [S1]
|
||||
- PDO: `$conn->exec($sql); $last_id = $conn->lastInsertId(); echo "Last inserted ID is: " . $last_id;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 새로 삽입된 레코드의 ID를 즉시 확인해 후속 작업(예: 관련 레코드 연결)에 사용하는 것이 실전 활용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Retrieving the last inserted ID across three APIs (PHP):
|
||||
```php
|
||||
// MySQLi OOP:
|
||||
$last_id = $conn->insert_id;
|
||||
// MySQLi procedural:
|
||||
$last_id = mysqli_insert_id($conn);
|
||||
// PDO:
|
||||
$last_id = $conn->lastInsertId();
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Insert]], [[PHP MySQL Insert Multiple]]
|
||||
- **참조 맥락:** 삽입 직후 ID 조회 — 다중 레코드 삽입(Insert Multiple) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Get Last Inserted ID — https://www.w3schools.com/php/php_mysql_insert_lastid.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Get Last Inserted ID" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: php-mysql-insert-multiple
|
||||
title: "PHP MySQL Insert Multiple"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["multi_query", "PHP MySQL 다중 삽입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "mysql", "insert"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_insert_multiple.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Insert Multiple]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Inserting multiple rows in ONE query requires switching from `query()`/`exec()` to a special MULTI-query method (`multi_query()` in MySQLi) — a single `INSERT INTO` statement with several comma-separated value groups isn't executed the same way as a normal single-row insert, since MySQLi treats it as a batch statement requiring its own dedicated function. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Multi-row INSERT syntax** — one `INSERT INTO table (cols) VALUES (...), (...), (...)` with comma-separated parenthesized value groups. [S1]
|
||||
- **`$conn->multi_query($sql)`** (MySQLi OOP) — required instead of the regular `query()` for multi-statement/multi-row inserts. [S1]
|
||||
- **`mysqli_multi_query($conn, $sql)`** (MySQLi procedural) — the equivalent function form. [S1]
|
||||
- **PDO uses the regular `exec()`** — no special multi-query method needed for PDO. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Multi-row insert syntax: `$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES ('John', 'Doe', 'john@example.com'), ('Mary', 'Moe', 'mary@example.com'), ('Julie', 'Dooley', 'julie@example.com')";`. [S1]
|
||||
- MySQLi OOP execution: `if ($conn->multi_query($sql) === TRUE) { echo "New records inserted successfully"; }`. [S1]
|
||||
- MySQLi procedural execution: `if (mysqli_multi_query($conn, $sql)) { echo "New records inserted successfully"; }`. [S1]
|
||||
- PDO execution (regular exec, no multi-query variant needed): `$conn->exec($sql); echo "New records inserted successfully";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **MySQLi에서만 필요한 특수 함수**: 다중 행 삽입 시 MySQLi는 일반 query() 대신 multi_query()를 써야 하지만, PDO는 일반 exec()로 충분하다는 API별 차이가 명확히 드러남. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 3명의 게스트를 한 번의 쿼리로 삽입하는 것이 배치 삽입의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Multi-row insert requiring multi_query() in MySQLi (PHP):
|
||||
```php
|
||||
$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES
|
||||
('John', 'Doe', 'john@example.com'),
|
||||
('Mary', 'Moe', 'mary@example.com'),
|
||||
('Julie', 'Dooley', 'julie@example.com')";
|
||||
if ($conn->multi_query($sql) === TRUE) { // note: multi_query, not query
|
||||
echo "New records inserted successfully";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Insert Last ID]], [[PHP MySQL Prepared Statements]]
|
||||
- **참조 맥락:** 배치 삽입 — 준비된 문장(Prepared Statements) 챕터로 이어짐(SQL 인젝션 방지).
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Insert Multiple Records — https://www.w3schools.com/php/php_mysql_insert_multiple.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Insert Multiple Records" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: php-mysql-intro
|
||||
title: "PHP MySQL Intro"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["PHP MySQL 개요"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "mysql", "database"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_intro.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP combined with MySQL is explicitly framed as cross-platform in a specific direction — you can DEVELOP on Windows and SERVE on Unix — highlighting that the development and production environments don't need to match, a practical deployment flexibility called out from the very first chapter. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **MySQL** — a fast, free, widely-used database system, developed by Oracle Corporation, using standard SQL. [S1]
|
||||
- **Table structure** — data stored in tables (columns + rows); a database groups related tables (e.g., Employees, Products, Customers, Orders). [S1]
|
||||
- **Query** — a request for specific data, e.g. `SELECT LastName FROM Employees`. [S1]
|
||||
- **Scale** — MySQL is the de-facto standard for huge-volume sites (Facebook, Twitter, Wikipedia scale) but also scales down to embedded use. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Example query: `SELECT LastName FROM Employees` — selects all data in the LastName column. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Facebook/Twitter/Wikipedia급 대용량 서비스가 MySQL을 사용한다는 점이 확장성의 근거로 제시된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
해당 챕터는 개념 소개 중심으로 별도 PHP 코드 예제가 없음 — 다음 챕터([[PHP MySQL Connect]])에서 실제 연결 코드가 시작된다.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Connect]], [[SQL Tutorial]]
|
||||
- **참조 맥락:** PHP-MySQL 연동 섹션의 도입부 — 연결(Connect) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Database — https://www.w3schools.com/php/php_mysql_intro.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Database" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-mysql-prepared-statements
|
||||
title: "PHP MySQL Prepared Statements"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["bind_param", "SQL injection prevention", "PHP MySQL 준비된 문장"]
|
||||
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", "mysql", "prepared-statements", "security"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_prepared_statements.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Prepared Statements]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Prepared statements defeat SQL injection specifically because parameter values are transmitted via a SEPARATE protocol from the SQL command itself — the source frames it precisely: "parameter values need not be correctly escaped... if the original statement template is not derived from external input, SQL injection cannot occur," meaning the security guarantee is structural, not just a matter of careful escaping. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Two-phase model** — Prepare (send an SQL template with `?` placeholders, server parses/compiles/optimizes without executing) then Execute (bind actual values, run — repeatable with different values). [S1]
|
||||
- **Four advantages** — reduced parsing time (prepared once, executed many times), minimized bandwidth (send only params, not the whole query), security (structural SQL-injection resistance), cleaner code (data separated from SQL). [S1]
|
||||
- **MySQLi `bind_param("types", ...vars)`** — binds variables to `?` placeholders; type string uses `i` (integer), `d` (double), `s` (string), `b` (binary) — one letter per parameter. [S1]
|
||||
- **PDO question-mark style** — `$stmt->execute(['John', 'Doe', ...])` — positional array of values. [S1]
|
||||
- **PDO named-parameter style** — `:firstname` placeholders with `$stmt->bindParam(':firstname', $var, PDO::PARAM_STR)`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- MySQLi prepared insert: `$sql = "INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)"; $stmt = $conn->prepare($sql); $stmt->bind_param("sss", $firstname, $lastname, $email); $firstname = "John"; $lastname = "Doe"; $email = "john@example.com"; $stmt->execute();` — reused with different variable values for subsequent inserts. [S1]
|
||||
- PDO positional: `$stmt = $conn->prepare($sql); $stmt->execute(['John', 'Doe', 'john@example.com']);`. [S1]
|
||||
- PDO named: `$stmt->bindParam(':firstname', $firstname, PDO::PARAM_STR); ... $stmt->execute();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **구조적 보안 보장**: 준비된 문장은 값이 SQL 명령과 별도 프로토콜로 전송되므로, 원본 템플릿이 외부 입력에서 유래하지 않는 한 SQL 인젝션 자체가 발생할 수 없다는 구조적 안전성이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 동일한 prepare()문을 재사용해 서로 다른 값으로 세 번 execute()하는 것이 준비된 문장의 성능 이점을 보여주는 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reusing one prepared statement with different bound values (PHP/MySQLi):
|
||||
```php
|
||||
$stmt = $conn->prepare("INSERT INTO MyGuests (firstname, lastname, email) VALUES (?, ?, ?)");
|
||||
$stmt->bind_param("sss", $firstname, $lastname, $email);
|
||||
$firstname = "John"; $lastname = "Doe"; $email = "john@example.com";
|
||||
$stmt->execute();
|
||||
$firstname = "Mary"; $lastname = "Moe"; $email = "mary@example.com";
|
||||
$stmt->execute(); // same statement, new values, no re-parsing
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Insert Multiple]], [[PHP MySQL Select]], [[PHP Form Validation]]
|
||||
- **참조 맥락:** SQL 인젝션 방지의 핵심 기법 — 데이터 조회(Select) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Prepared Statements — https://www.w3schools.com/php/php_mysql_prepared_statements.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Prepared Statements" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-mysql-select
|
||||
title: "PHP MySQL Select"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fetch_assoc", "num_rows", "PHP MySQL 데이터 조회"]
|
||||
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", "mysql", "select"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_select.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Select]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Retrieving results requires checking the row count BEFORE looping — `$result->num_rows > 0` gates the `while` loop, since calling `fetch_assoc()` on a zero-row result set just returns false immediately, making the explicit "0 results" branch necessary for clear user feedback rather than a silently empty output. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`SELECT column1, column2 FROM table`** — selects specific columns; `SELECT *` selects all columns. [S1]
|
||||
- **`$conn->query($sql)`** — executes and returns a result object/set. [S1]
|
||||
- **`$result->num_rows`** (MySQLi OOP) / **`mysqli_num_rows($result)`** (procedural) — row count check before looping. [S1]
|
||||
- **`$result->fetch_assoc()`** (MySQLi OOP) / **`mysqli_fetch_assoc($result)`** (procedural) — pulls one row as an associative array per call; used inside a `while` loop. [S1]
|
||||
- **PDO equivalents** — `$result->rowCount()` for row count, `$result->fetch()` for one row at a time. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- MySQLi OOP select+loop: `$sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>"; } } else { echo "0 results"; }`. [S1]
|
||||
- MySQLi procedural equivalent: `$result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) {...} }`. [S1]
|
||||
- PDO equivalent: `$result = $conn->query($sql); if ($result->rowCount() > 0) { while($row = $result->fetch()) {...} } else { echo "No records found."; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — id/firstname/lastname을 HTML 테이블로 렌더링하는 것이 조회 결과 출력의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Selecting and looping through results, checking row count first (PHP/MySQLi):
|
||||
```php
|
||||
$sql = "SELECT id, firstname, lastname FROM MyGuests";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "id: " . $row["id"] . " - Name: " . $row["firstname"] . " " . $row["lastname"] . "<br>";
|
||||
}
|
||||
} else {
|
||||
echo "0 results";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Prepared Statements]], [[PHP MySQL Select Where]]
|
||||
- **참조 맥락:** 데이터 조회 기초 — WHERE 조건 필터링(Select Where) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Select Data — https://www.w3schools.com/php/php_mysql_select.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Select Data" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: php-mysql-select-limit
|
||||
title: "PHP MySQL Select Limit"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["LIMIT OFFSET", "PHP MySQL 결과 제한"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "mysql", "limit"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_select_limit.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Select Limit]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`LIMIT 15, 10` and `LIMIT 10 OFFSET 15` return the IDENTICAL result, but the numbers are REVERSED between the two forms — the comma syntax puts the offset first and count second, while the OFFSET keyword syntax puts count first and offset second, a subtle inversion the source explicitly flags to avoid confusion. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`LIMIT n`** — returns only the first `n` records. [S1]
|
||||
- **Purpose** — performance on large tables; avoids returning huge result sets unnecessarily. [S1]
|
||||
- **`LIMIT n OFFSET m`** — returns `n` records starting after skipping `m` records (i.e., starting at record m+1). [S1]
|
||||
- **Comma shorthand — `LIMIT m, n`** — same result as `LIMIT n OFFSET m`, but note the argument ORDER is reversed (offset first here, count first in the OFFSET form). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- First 30 records: `$sql = "SELECT * FROM Orders LIMIT 30";`. [S1]
|
||||
- Records 16-25 via OFFSET: `$sql = "SELECT * FROM Orders LIMIT 10 OFFSET 15";` — "return only 10 records, start on record 16 (OFFSET 15)". [S1]
|
||||
- Same result via comma shorthand: `$sql = "SELECT * FROM Orders LIMIT 15, 10";` — note the numbers are reversed compared to the OFFSET form. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **콤마 문법의 숫자 순서 반전**: LIMIT n OFFSET m과 LIMIT m, n이 동일한 결과를 내지만 숫자 순서가 반대라는 점이 혼동 방지를 위해 명시적으로 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 페이지네이션(16~25번째 레코드 조회)이 LIMIT+OFFSET 활용의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two equivalent syntaxes for the same paginated range, with reversed argument order (SQL):
|
||||
```sql
|
||||
SELECT * FROM Orders LIMIT 10 OFFSET 15; -- 10 records starting at record 16
|
||||
SELECT * FROM Orders LIMIT 15, 10; -- same result, numbers reversed
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Update]], [[PHP XML Parsers]]
|
||||
- **참조 맥락:** MySQL 섹션의 마지막 — XML 파싱 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Limit Data Selections — https://www.w3schools.com/php/php_mysql_select_limit.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Limit Data Selections" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: php-mysql-select-order-by
|
||||
title: "PHP MySQL Select Order By"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["ORDER BY clause", "PHP MySQL 정렬 조회"]
|
||||
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", "mysql", "order-by"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_select_orderby.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Select Order By]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`ORDER BY` sorts ascending by default with NO keyword needed — only descending order requires the explicit `DESC` keyword, meaning the "natural" reading direction (ascending) is the silent default while the "unnatural" direction requires deliberate opt-in. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`ORDER BY column ASC|DESC`** — sorts the result set; ascending is default (no keyword needed), descending needs `DESC`. [S1]
|
||||
- **Same PHP wrapper pattern** — again, only the SQL string changes (`ORDER BY lastname` appended); connection/fetch/loop code stays identical. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Ordered select: `$sql = "SELECT id, firstname, lastname FROM MyGuests ORDER BY lastname"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>"; } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 성(lastname) 기준 오름차순 정렬 조회가 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Ordering results by a column, ascending by default (SQL):
|
||||
```sql
|
||||
SELECT id, firstname, lastname FROM MyGuests ORDER BY lastname
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Select Where]], [[PHP MySQL Delete]]
|
||||
- **참조 맥락:** 정렬 조회 — 데이터 삭제(Delete) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL The ORDER BY Clause — https://www.w3schools.com/php/php_mysql_select_orderby.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL The ORDER BY Clause" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-mysql-select-where
|
||||
title: "PHP MySQL Select Where"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["WHERE clause", "PHP MySQL 필터링"]
|
||||
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", "mysql", "where"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_select_where.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Select Where]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter reuses the EXACT same PHP structure as the plain SELECT chapter — only the SQL string itself changes (`... WHERE lastname='Doe'` appended) — demonstrating that filtering logic lives entirely in the SQL layer, with zero changes needed to the PHP fetch/loop code around it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`WHERE column operator value`** — filters records matching a condition. [S1]
|
||||
- **Same PHP wrapper as plain SELECT** — connection, `query()`, `num_rows`/`rowCount()` check, `fetch_assoc()`/`fetch()` loop are all identical; only the SQL string differs. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Filtered select: `$sql = "SELECT id, firstname, lastname FROM MyGuests WHERE lastname='Doe'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>"; } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — lastname='Doe' 조건으로 특정 게스트만 조회하는 것이 필터링의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Filtering results with WHERE, same PHP structure as plain SELECT (PHP/MySQLi):
|
||||
```php
|
||||
$sql = "SELECT id, firstname, lastname FROM MyGuests WHERE lastname='Doe'";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "id: " . $row["id"] . " - Name: " . $row["firstname"] . " " . $row["lastname"] . "<br>";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Select]], [[PHP MySQL Select Order By]]
|
||||
- **참조 맥락:** WHERE 조건 필터링 — ORDER BY 정렬(Select Order By) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL The WHERE Clause — https://www.w3schools.com/php/php_mysql_select_where.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL The WHERE Clause" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: php-mysql-update
|
||||
title: "PHP MySQL Update"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["UPDATE SET", "PHP MySQL 수정"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "mysql", "update"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_mysql_update.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP MySQL Update]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`UPDATE` shares the exact same danger as `DELETE` — omitting `WHERE` updates ALL records in the table, not just none — meaning both destructive SQL operations (mass-delete and mass-overwrite) are gated behind the same single safety mechanism, the WHERE clause. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`UPDATE table SET col=val WHERE condition`** — modifies matching records. [S1]
|
||||
- **WHERE limits the blast radius** — omitting it updates EVERY record in the table (same risk pattern as DELETE). [S1]
|
||||
- **Executed like DELETE/INSERT** — `$conn->query($sql)` (MySQLi OOP), `mysqli_query($conn, $sql)` (procedural), `$conn->exec($sql)` (PDO). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Update by ID: `$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; }`. [S1]
|
||||
- Before/after table state: id=2's lastname changes from "Moe" to "Doe" after the update, all other rows/columns unchanged. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **WHERE 절 생략의 파괴적 결과**: DELETE와 마찬가지로 WHERE 절을 생략하면 테이블의 모든 레코드가 수정된다는 점이 동일하게 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — id=2 게스트의 성만 변경하는 것이 안전한 조건부 수정의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Updating a specific record, WHERE clause required (SQL/PHP):
|
||||
```php
|
||||
$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2"; // WHERE prevents updating every row
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
echo "Record updated successfully";
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP MySQL Delete]], [[PHP MySQL Select Limit]]
|
||||
- **참조 맥락:** 레코드 수정 — 결과 제한(Select Limit) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP MySQL Update Data — https://www.w3schools.com/php/php_mysql_update.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Update Data" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-namespaces
|
||||
title: "PHP Namespaces"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["namespace keyword", "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", "namespaces"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_namespaces.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Namespaces]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`namespace` MUST be the very first statement in a PHP file — even a preceding `echo "Hello World!";` before the namespace declaration is explicitly shown as INVALID code, meaning nothing (not even innocuous output) can come before it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Namespace** — groups classes/interfaces/functions/constants under a name to prevent naming collisions (e.g., two unrelated `Table` classes — one for HTML, one for furniture). [S1]
|
||||
- **Must be declared first** — `namespace Html;` must be the absolute first line of the file. [S1]
|
||||
- **Nested namespaces** — `namespace Code\Html;` for further organization. [S1]
|
||||
- **Accessing from outside the namespace** — requires the full qualifier: `new Html\Table();`. [S1]
|
||||
- **Inside the namespace** — no qualifier needed (`new Table();`) once you've declared `namespace Html;` at the top. [S1]
|
||||
- **`use ... as ...`** — creates an alias for a namespace or class, shortening repeated references. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaring and using within a namespace: `namespace Html; class Table { ... } $table = new \Html\Table();`. [S1]
|
||||
- Accessing from outside: `$table = new Html\Table(); $row = new Html\Row();`. [S1]
|
||||
- Accessing after declaring the same namespace: `namespace Html; $table = new Table(); $row = new Row();`. [S1]
|
||||
- Namespace alias: `use Html as H; $table = new H\Table();`. [S1]
|
||||
- Class alias: `use Html\Table as T; $table = new T();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **네임스페이스 선언 위치의 절대적 제약**: echo 문 하나라도 namespace 선언보다 앞에 오면 무효한 코드가 된다는 점이 명시적으로 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — HTML용 Table 클래스와 가구용 Table 클래스를 네임스페이스로 분리하는 것이 이름 충돌 방지의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Namespace must be the first statement in the file (PHP):
|
||||
```php
|
||||
<?php
|
||||
namespace Html; // must be the very first line
|
||||
class Table {
|
||||
public $title = "";
|
||||
public $rows = 0;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Static Properties]], [[PHP Iterables]]
|
||||
- **참조 맥락:** 이름 충돌 방지를 위한 그룹화 — 이터러블(Iterables) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Namespaces — https://www.w3schools.com/php/php_namespaces.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Namespaces" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-numbers
|
||||
title: "PHP Numbers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["is_int", "is_float", "NAN", "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", "numbers"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_numbers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Numbers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`4 * 2.5` results in a FLOAT (10.0), not an integer, even though the mathematical result is a whole number — PHP's rule is that if ANY operand in an arithmetic expression is a float, the result is always stored as float, regardless of whether the value happens to be whole. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Three numeric types** — Integer, Float, Numeric Strings; plus Infinity and NaN as special number-related values. [S1]
|
||||
- **`is_int()` / `is_float()`** — type checks. [S1]
|
||||
- **Integer range** — platform-dependent (32-bit: ±2,147,483,647; 64-bit: much larger); overflow silently becomes a float. [S1]
|
||||
- **Integer notations** — decimal, hex (`0x`), octal (`0`), binary (`0b`). [S1]
|
||||
- **`PHP_INT_MAX` / `PHP_INT_MIN` / `PHP_INT_SIZE`** — predefined integer limit constants. [S1]
|
||||
- **`PHP_FLOAT_MAX` / `MIN` / `DIG` / `EPSILON`** (PHP 7.2+) — predefined float precision constants. [S1]
|
||||
- **`is_finite()` / `is_infinite()`** — range checks against platform float limits. [S1]
|
||||
- **`NAN`** ("Not A Number") — returned by invalid math operations; checked via `is_nan()`. [S1]
|
||||
- **`is_numeric()`** — true for both actual numbers AND numeric strings (e.g., `"5985"`). [S1]
|
||||
- **`intval()`** — extracts the integer value from a float or numeric-leading string. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Float contagion rule: `4 * 2.5` is 10, but stored as float because one operand (2.5) is a float. [S1]
|
||||
- Invalid math yields NAN: `$x = acos(8); var_dump($x); var_dump(is_nan($x)); // true`. [S1]
|
||||
- Numeric string check: `$x = "59.85" + 100; var_dump(is_numeric($x)); // true (arithmetic result)`. [S1]
|
||||
- intval on string: `$x = "23465.768"; echo intval($x); // 23465`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **부동소수점 전염 규칙**: 연산 결과가 정수 값이어도 피연산자 중 하나가 float이면 결과 타입은 항상 float이 된다는 점이 명시적으로 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — is_numeric()으로 사용자 입력이 숫자 형태인지 검증하는 것이 폼 처리의 실전 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Float contagion in arithmetic (PHP):
|
||||
```php
|
||||
$result = 4 * 2.5;
|
||||
var_dump($result); // float(10) — not int, because 2.5 is a float
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Data Types]], [[PHP Casting]], [[PHP Math]]
|
||||
- **참조 맥락:** 숫자 타입의 세부 규칙 — 캐스팅(Casting)/수학함수(Math) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Numbers — https://www.w3schools.com/php/php_numbers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Numbers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -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).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-oop-classes-abstract
|
||||
title: "PHP OOP Classes Abstract"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["abstract methods", "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", "abstract"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_classes_abstract.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Classes Abstract]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An abstract method's implementation in the child class must match or LOOSEN the access modifier, never tighten it — if the parent declares `abstract protected function`, the child MUST implement it as `protected` or `public`, but NEVER `private`, and the child can freely ADD optional parameters beyond the required ones the parent specified. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Abstract class** — contains at least one abstract method (declared but not implemented); the implementation is deferred to child classes. [S1]
|
||||
- **Abstract method** — declared with `abstract`, no body; forces every child class to implement it. [S1]
|
||||
- **Rule 1: same name** — child method must have the exact same name, redeclaring the parent's abstract method. [S1]
|
||||
- **Rule 2: same or looser access modifier** — protected can only become protected or public in the child, never private. [S1]
|
||||
- **Rule 3: same required argument count, optional extras allowed** — the child method must accept the same required parameters, but MAY add optional ones. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Abstract base with two implementing children: `abstract class Car { public $name; public function __construct($name) { $this->name = $name; } abstract public function intro(); } class Audi extends Car { public function intro() { return "German quality! I'm an $this->name!"; } } class Citroen extends Car { public function intro() { return "French extravagance! I'm a $this->name!"; } }`. [S1]
|
||||
- Abstract method with an argument: `abstract class ParentClass { abstract protected function prefixName($name); } class ChildClass extends ParentClass { public function prefixName($name) { ... } }`. [S1]
|
||||
- Child adding optional arguments beyond the parent's requirement: `public function prefixName($name, $separator = ".", $greet = "Dear") { ... }` — valid even though the parent's abstract declares only `$name`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **접근 제어자 완화만 허용**: 자식 클래스 구현부는 부모의 abstract 메서드보다 접근 제어자를 더 제한적으로 만들 수 없다는 규칙이 명시됨(protected → protected/public만 가능, private 불가). [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Car 추상 클래스를 Audi/Citroen이 각자 다른 intro() 구현으로 확장하는 것이 다형성의 대표 실전 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Abstract class forcing implementation in child classes (PHP):
|
||||
```php
|
||||
abstract class Car {
|
||||
public $name;
|
||||
public function __construct($name) { $this->name = $name; }
|
||||
abstract public function intro(); // no body — child must implement
|
||||
}
|
||||
class Audi extends Car {
|
||||
public function intro() { return "German quality! I'm an $this->name!"; }
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Constants]], [[PHP OOP Interfaces]]
|
||||
- **참조 맥락:** 추상 클래스 — 인터페이스(Interfaces) 챕터와 직접 비교됨.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Abstract Classes — https://www.w3schools.com/php/php_oop_classes_abstract.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Abstract Classes" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: php-oop-classes-objects
|
||||
title: "PHP OOP Classes Objects"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["instanceof", "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", "classes"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_classes_objects.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Classes Objects]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`$this` inside a method always refers to the specific object it was called on — so `$apple->set_details('Apple', 'Red')` and `$banana->set_details('Banana', 'Yellow')` run the EXACT SAME method code, yet each object ends up with its own independent property values, since `$this` resolves differently per call. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`class` keyword** — defines a class with properties (variables) and methods (functions) inside `{ }`. [S1]
|
||||
- **`$this`** — refers to the current object's own properties/methods within a method. [S1]
|
||||
- **`new` keyword** — creates an object instance from a class. [S1]
|
||||
- **`instanceof`** — checks whether an object belongs to a specific class, returning a boolean. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Class definition: `class Fruit { public $name; public $color; function set_details($name, $color) { $this->name = $name; $this->color = $color; } function get_details() { echo "Name: " . $this->name . ". Color: " . $this->color .".<br>"; } }`. [S1]
|
||||
- Object creation and independent state: `$apple = new Fruit(); $apple->set_details('Apple', 'Red'); $banana = new Fruit(); $banana->set_details('Banana', 'Yellow');` — each object holds distinct values. [S1]
|
||||
- instanceof check: `var_dump($apple instanceof Fruit); // true`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Fruit 클래스에서 Apple/Banana 객체를 각각 생성하는 것이 인스턴스 독립성의 대표 예시다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two independent object instances from the same class (PHP):
|
||||
```php
|
||||
class Fruit {
|
||||
public $name;
|
||||
public $color;
|
||||
function set_details($name, $color) {
|
||||
$this->name = $name;
|
||||
$this->color = $color;
|
||||
}
|
||||
}
|
||||
$apple = new Fruit();
|
||||
$apple->set_details('Apple', 'Red');
|
||||
$banana = new Fruit();
|
||||
$banana->set_details('Banana', 'Yellow');
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP What Is]], [[PHP OOP Constructor]], [[PHP OOP Access Modifiers]]
|
||||
- **참조 맥락:** 클래스/객체 선언 기초 — 생성자(Constructor) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Classes and Objects — https://www.w3schools.com/php/php_oop_classes_objects.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Classes and Objects" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: php-oop-constants
|
||||
title: "PHP OOP Constants"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["class constants", "scope resolution operator", "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", "constants"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_constants.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Constants]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Class constants use TWO different keywords depending on whether you're inside or outside the class — `ClassName::CONSTANT` from outside, but `self::CONSTANT` from inside a method — even though both use the same `::` scope resolution operator, meaning the class-name vs. self choice signals your calling context. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Class constant** — declared with `const`; fixed value, cannot change once set; default visibility is `public`. [S1]
|
||||
- **Case-sensitive but conventionally uppercase** — best practice names constants in ALL_CAPS. [S1]
|
||||
- **Access from outside** — `ClassName::CONSTANT_NAME`. [S1]
|
||||
- **Access from inside** — `self::CONSTANT_NAME`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Outside access: `class Goodbye { const MESSAGE = "Thank you for visiting W3Schools.com!"; } echo Goodbye::MESSAGE;`. [S1]
|
||||
- Inside access (self): `class Goodbye { const MESSAGE = "..."; public function bye() { echo self::MESSAGE; } } $goodbye = new Goodbye(); $goodbye->bye();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 클래스 상수는 정적 메서드/속성 챕터에서 사용하는 :: 연산자를 먼저 익히는 단계다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Accessing a class constant from inside via self:: (PHP):
|
||||
```php
|
||||
class Goodbye {
|
||||
const MESSAGE = "Thank you for visiting W3Schools.com!";
|
||||
public function bye() {
|
||||
echo self::MESSAGE;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Inheritance]], [[PHP OOP Classes Abstract]], [[PHP OOP Static Properties]]
|
||||
- **참조 맥락:** :: 연산자를 이용한 클래스 상수 접근 — 추상 클래스(Abstract Classes) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Class Constants — https://www.w3schools.com/php/php_oop_constants.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Class Constants" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-oop-constructor
|
||||
title: "PHP OOP Constructor"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["__construct()", "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", "constructor"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_constructor.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Constructor]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`__construct()` eliminates the need to call a separate setter method after object creation — instead of `new Fruit(); $apple->set_details(...)` (two steps), the constructor lets `new Fruit('Apple', 'Red')` initialize properties in ONE step, directly reducing the code from the previous chapter's two-call pattern. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`__construct($params)`** — a special method automatically invoked whenever `new` creates an object; name starts with double underscore. [S1]
|
||||
- **Accepts arguments** — passed at creation time: `new Fruit("Apple", "Red")`. [S1]
|
||||
- **Purpose** — dynamic initialization, replacing a separate setter call. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Constructor-based initialization: `class Fruit { public $name; public $color; function __construct($name, $color) { $this->name = $name; $this->color = $color; } function get_details() { echo "Name: " . $this->name . ". Color: " . $this->color .".<br>"; } } $apple = new Fruit('Apple', 'Red'); $apple->get_details();`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 생성자로 이름/색상을 한 번에 초기화하는 것이 setter 메서드 호출을 줄이는 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Constructor-based initialization in one step (PHP):
|
||||
```php
|
||||
class Fruit {
|
||||
public $name;
|
||||
public $color;
|
||||
function __construct($name, $color) {
|
||||
$this->name = $name;
|
||||
$this->color = $color;
|
||||
}
|
||||
}
|
||||
$apple = new Fruit('Apple', 'Red'); // initialized directly, no separate setter call
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Classes Objects]], [[PHP OOP Destructor]]
|
||||
- **참조 맥락:** 객체 초기화 메서드 — 소멸자(Destructor) 챕터로 직접 이어짐(생성자의 반대 개념).
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Constructor Method — https://www.w3schools.com/php/php_oop_constructor.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Constructor Method" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-oop-destructor
|
||||
title: "PHP OOP Destructor"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["__destruct()", "PHP 소멸자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "oop", "destructor"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_destructor.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Destructor]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`__destruct()` runs automatically at the END of script execution (or when an object is explicitly destroyed) with NO explicit call needed — it's the structural mirror of `__construct()`, firing on the opposite lifecycle event (teardown vs. setup) rather than being invoked by user code. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`__destruct()`** — automatically called when an object is destroyed OR when the script finishes execution. [S1]
|
||||
- **Opposite of `__construct()`** — fires at teardown instead of creation. [S1]
|
||||
- **No arguments** — unlike the constructor, `__destruct()` takes no parameters. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Constructor + destructor pair: `class Fruit { public $name; public $color; function __construct($name, $color) { $this->name = $name; $this->color = $color; } function __destruct() { echo "Name: " . $this->name . ". Color: " . $this->color .".<br>"; } } $apple = new Fruit('Apple', 'Red'); $banana = new Fruit('Banana', 'Yellow');` — the destructor for each object fires automatically at script end, printing both fruits' details even though `__destruct()` was never explicitly called. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 생성자/소멸자 쌍이 코드 양을 줄이는 데 유용하다는 점이 팁으로 강조된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Destructor firing automatically at script end (PHP):
|
||||
```php
|
||||
class Fruit {
|
||||
public $name;
|
||||
public $color;
|
||||
function __construct($name, $color) {
|
||||
$this->name = $name;
|
||||
$this->color = $color;
|
||||
}
|
||||
function __destruct() {
|
||||
echo "Name: " . $this->name . ". Color: " . $this->color .".<br>";
|
||||
}
|
||||
}
|
||||
$apple = new Fruit('Apple', 'Red'); // __destruct() runs automatically at script end
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Constructor]], [[PHP OOP Access Modifiers]]
|
||||
- **참조 맥락:** 생성자의 반대 개념(소멸) — 접근 제어자(Access Modifiers) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Destructor Method — https://www.w3schools.com/php/php_oop_destructor.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Destructor Method" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: php-oop-inheritance
|
||||
title: "PHP OOP Inheritance"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["extends", "final keyword", "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", "inheritance"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_inheritance.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Inheritance]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Calling a `protected` method from OUTSIDE the class fails, but calling that SAME protected method from WITHIN a subclass's own method (via `$this->intro()`) succeeds — the exact rule from access modifiers applies identically to methods, and the source proves it with a direct pass/fail comparison of the two call sites. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`extends`** — inherits public and protected properties/methods from a parent class. [S1]
|
||||
- **Private members are NOT inherited** — a child class cannot access a parent's private methods/properties at all. [S1]
|
||||
- **Method overriding** — redefining a method with the same name in the child class replaces the parent's version. [S1]
|
||||
- **`final` on a class** — prevents any class from extending it. [S1]
|
||||
- **`final` on a method** — prevents child classes from overriding that specific method. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic inheritance: `class Fruit { public $name; public $color; public function __construct($name, $color) {...} public function intro() {...} } class Strawberry extends Fruit { public function message() {...} } $strawberry = new Strawberry("Strawberry", "red"); $strawberry->intro(); $strawberry->message();` — Strawberry uses Fruit's constructor/intro plus its own message(). [S1]
|
||||
- Protected method fails from outside: `$strawberry->intro(); // ERROR if intro() is protected`. [S1]
|
||||
- Protected method works from inside a child method: `public function message() { $this->intro(); }` — calling `$this->intro()` from within `message()` succeeds. [S1]
|
||||
- Overriding: child class `Strawberry` redefines `__construct()` and `intro()` with the same names, completely replacing the parent's versions (adding a `$weight` property along the way). [S1]
|
||||
- `final` prevents inheritance: `final class Fruit {...} class Strawberry extends Fruit {...} // error`. [S1]
|
||||
- `final` prevents method override: `class Fruit { final public function intro() {...} } class Strawberry extends Fruit { public function intro() {...} // error }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **protected 메서드 호출 위치에 따른 성패**: 클래스 외부에서 호출하면 에러, 파생 클래스 내부 메서드에서 $this로 호출하면 성공한다는 점이 두 대비 예제로 직접 증명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Strawberry가 Fruit의 생성자/메서드를 재정의(override)하며 weight 속성을 추가하는 것이 실전 오버라이딩의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Overriding a parent's constructor and method (PHP):
|
||||
```php
|
||||
class Fruit {
|
||||
public $name;
|
||||
public $color;
|
||||
public function __construct($name, $color) { $this->name = $name; $this->color = $color; }
|
||||
public function intro() { echo "The fruit is $this->name and the color is $this->color."; }
|
||||
}
|
||||
class Strawberry extends Fruit {
|
||||
public $weight;
|
||||
public function __construct($name, $color, $weight) {
|
||||
$this->name = $name; $this->color = $color; $this->weight = $weight;
|
||||
}
|
||||
public function intro() {
|
||||
echo "A $this->name is $this->color, and the weight is $this->weight gram.";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Access Modifiers]], [[PHP OOP Constants]], [[PHP OOP Classes Abstract]]
|
||||
- **참조 맥락:** 클래스 상속과 메서드 오버라이딩 — 클래스 상수(Constants) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Inheritance — https://www.w3schools.com/php/php_oop_inheritance.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: php-oop-interfaces
|
||||
title: "PHP OOP Interfaces"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["implements keyword", "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", "interfaces"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_interfaces.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Interfaces]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A class can `implements` an interface WHILE ALSO `extends`-ing another class simultaneously — this is the key structural advantage over abstract classes explicitly called out in the comparison table, since PHP only allows single class inheritance but interfaces don't consume that one inheritance slot. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`interface`** — defines a set of public methods a class MUST implement, without specifying HOW. [S1]
|
||||
- **`implements`** — the keyword a class uses to fulfill an interface's contract; must implement ALL declared methods. [S1]
|
||||
- **Interface vs. abstract class differences** — interfaces cannot have properties (abstract classes can); ALL interface methods must be public and are implicitly abstract (no `abstract` keyword needed); a class can implement an interface while still extending another class. [S1]
|
||||
- **Polymorphism via interfaces** — multiple classes implementing the same interface can be used interchangeably. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic interface: `interface Animal { public function makeSound(); } class Cat implements Animal { public function makeSound() { echo "Meow"; } } class Dog implements Animal { public function makeSound() { echo "Woff"; } }`. [S1]
|
||||
- Multi-method interface: `interface Animal { public function fromFamily(); public function makeSound(); }` — both Cat and Dog must implement BOTH methods. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **인터페이스 vs 추상 클래스의 핵심 차이**: 인터페이스는 속성을 가질 수 없고 모든 메서드가 public+abstract이며, 클래스 상속과 동시에 구현 가능하다는 점이 표로 명확히 대비됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Cat/Dog가 동일한 Animal 인터페이스를 구현해 일관된 방식으로 다룰 수 있는 것(다형성)이 실전 활용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two classes implementing the same interface uniformly (PHP):
|
||||
```php
|
||||
interface Animal {
|
||||
public function fromFamily();
|
||||
public function makeSound();
|
||||
}
|
||||
class Cat implements Animal {
|
||||
public function fromFamily() { echo "From family: Felidae.<br>"; }
|
||||
public function makeSound() { echo "Sound: Meow."; }
|
||||
}
|
||||
class Dog implements Animal {
|
||||
public function fromFamily() { echo "From family: Canidae.<br>"; }
|
||||
public function makeSound() { echo "Sound: Woff."; }
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Classes Abstract]], [[PHP OOP Traits]]
|
||||
- **참조 맥락:** 다형성을 위한 메서드 계약 — 트레이트(Traits) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Interfaces — https://www.w3schools.com/php/php_oop_interfaces.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Interfaces" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: php-oop-static-methods
|
||||
title: "PHP OOP Static Methods"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["static keyword", "parent::", "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", "static"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_static_methods.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[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):
|
||||
```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)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Traits]], [[PHP OOP Static Properties]]
|
||||
- **참조 맥락:** 인스턴스 없이 호출 가능한 메서드 — 정적 속성(Static Properties) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Static Methods — https://www.w3schools.com/php/php_oop_static_methods.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Static Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
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).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-oop-traits
|
||||
title: "PHP OOP Traits"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["trait keyword", "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", "traits"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_traits.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP Traits]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Traits solve a problem interfaces and single inheritance CAN'T — sharing actual method IMPLEMENTATIONS (not just contracts) across unrelated classes — and a single class can pull in MULTIPLE traits at once via a comma-separated `use` statement, something impossible with PHP's single-class-inheritance rule. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Trait** — declares methods (including abstract ones) reusable across multiple, otherwise unrelated classes; a mechanism for code reuse. [S1]
|
||||
- **`trait TraitName { ... }`** — defines a trait. [S1]
|
||||
- **`use TraitName;`** inside a class — pulls the trait's methods into that class. [S1]
|
||||
- **Any access modifier allowed** — trait methods can be public, private, or protected. [S1]
|
||||
- **Multiple traits** — `use trait1, trait2;` — comma-separated, letting one class combine several traits. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic trait usage: `trait message1 { public function msg1() { echo "PHP OOP is fun! "; } } class Welcome { use message1; } $obj = new Welcome(); $obj->msg1();`. [S1]
|
||||
- Two classes sharing one trait, using different subsets of its methods: `trait message1 { public function msg1() {...} public function msg2() {...} public function msg3() {...} } class Welcome { use message1; } class Welcome2 { use message1; }` — Welcome only calls `msg1()`, Welcome2 calls all three. [S1]
|
||||
- Multiple traits in one class: `class Welcome2 { use message1, message2; }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 여러 클래스가 같은 트레이트를 재사용해 메서드 중복 선언을 줄이는 것이 코드 재사용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A class combining multiple traits (PHP):
|
||||
```php
|
||||
trait message1 {
|
||||
public function msg1() { echo "PHP OOP is fun! "; }
|
||||
}
|
||||
trait message2 {
|
||||
public function msg2() { echo "Traits reduce code duplication!"; }
|
||||
}
|
||||
class Welcome2 {
|
||||
use message1, message2;
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.89
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Interfaces]], [[PHP OOP Static Methods]]
|
||||
- **참조 맥락:** 메서드 재사용 메커니즘 — 정적 메서드(Static Methods) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP OOP - Traits — https://www.w3schools.com/php/php_oop_traits.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP OOP Traits" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: php-oop-what-is
|
||||
title: "PHP OOP What Is"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["object-oriented programming", "PHP OOP 개요"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "oop"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_oop_what_is.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP OOP What Is]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP's OOP overview names five pillars up front (Classes/Objects, Encapsulation, Inheritance, Abstraction, Interfaces) as a package deal — the same five-concept structure the tutorial follows chapter by chapter, meaning "learning PHP OOP" is explicitly scoped as these five specific mechanisms, not an open-ended topic. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **OOP** — organizing code into classes/objects with properties and methods, vs. procedural's sequential step-by-step execution. [S1]
|
||||
- **Advantages** — clear structure, DRY-friendly maintainability, reusable applications with less code. [S1]
|
||||
- **Class** — a template for objects. [S1]
|
||||
- **Object** — an individual instance of a class; inherits properties/methods but has its own property values. [S1]
|
||||
- **Five OOP pillars in this tutorial** — Classes/Objects, Encapsulation (access modifiers), Inheritance, Abstraction (non-instantiable base classes), Interfaces (method contracts). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Fruit → Apple/Banana/Mango, Car → Volvo/Audi/Toyota illustrate class-vs-objects (same illustration used in Java's OOP intro). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — OOP 5대 개념(클래스/캡슐화/상속/추상화/인터페이스)의 개념적 도입부다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
해당 챕터는 개념 소개 중심으로 별도 코드 예제가 없음 — 다음 챕터([[PHP OOP Classes Objects]])에서 실제 클래스 선언 문법이 시작된다.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP OOP Classes Objects]], [[PHP OOP Inheritance]], [[Java OOP]]
|
||||
- **참조 맥락:** PHP OOP 섹션 전체의 개념적 도입부 — 클래스/객체 문법으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Object-Oriented Programming — https://www.w3schools.com/php/php_oop_what_is.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Object-Oriented Programming" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: php-operators
|
||||
title: "PHP Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["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", "operators"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_operators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP distinguishes `==` (equal) from `===` (identical) at the type level, not just the value level — `$x === $y` requires BOTH the value AND the data type to match, meaning `5 == "5"` is true but `5 === "5"` is false, a distinction that extends identically to array comparison operators too. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **8 operator groups** — Arithmetic, Assignment, Comparison, Increment/Decrement, Logical, String, Array, Conditional. [S1]
|
||||
- **`==` vs `===`** — equal (loose, value only) vs. identical (strict, value + type). [S1]
|
||||
- **`<=>`** (spaceship, PHP 7+) — returns negative/zero/positive based on relative order. [S1]
|
||||
- **Pre vs. post increment** — `++$x` returns the NEW value; `$x++` returns the OLD value, both then incrementing. [S1]
|
||||
- **String operators** — `.` (concat), `.=` (concat-assign). [S1]
|
||||
- **Array operators** — `+` (union), `==`/`===` (equality/identity with type-sensitivity difference). [S1]
|
||||
- **`?:`** (ternary) and **`??`** (null coalescing, PHP 7+) — conditional shorthand operators. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Comparison table includes: `==`, `===`, `!=`, `<>`, `!==`, `>`, `<`, `>=`, `<=`, `<=>` (spaceship). [S1]
|
||||
- Increment/decrement: `++$x` (pre-increment: increments then returns), `$x++` (post-increment: returns then increments). [S1]
|
||||
- Logical operators: `and`/`&&`, `or`/`||`, `xor`, `!`. [S1]
|
||||
- Null coalescing: `$x = expr1 ?? expr2;` — `expr2` used if `expr1` doesn't exist or is NULL. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **== 와 ===의 차이**: 값만 비교(==)하는 것과 값+타입을 모두 비교(===)하는 것이 배열 비교에도 동일하게 적용된다는 점이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — null 병합 연산자(??)가 기본값 설정 로직에서 자주 쓰이는 실전 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Null coalescing operator for default values (PHP):
|
||||
```php
|
||||
$x = $expr1 ?? "default value"; // uses $expr1 unless it's NULL/unset
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP If Else]], [[PHP If Operators]], [[PHP If Shorthand]]
|
||||
- **참조 맥락:** 모든 연산자의 개요 — 조건문(If Else) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Operators — https://www.w3schools.com/php/php_operators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-regex
|
||||
title: "PHP RegEx"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["regular expressions", "PHP 정규표현식"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "regex"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_regex.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP RegEx]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP regex patterns require an explicit DELIMITER character wrapping the pattern (`"/pattern/modifiers"`) — unlike some languages where the pattern is a bare string, and the delimiter itself is swappable (`#`, `~`, etc.) specifically so patterns containing literal `/` characters don't need extra escaping. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Syntax** — `"/pattern/modifiers"` — delimiter + pattern + optional modifiers. [S1]
|
||||
- **Delimiter rule** — any non-letter/digit/backslash/space character; `/` is most common, but `#`/`~` avoid clashing with patterns containing slashes. [S1]
|
||||
- **Modifiers** — `i` (case-insensitive), `m` (multiline — `^`/`$` match per-line not just whole-string), `u` (UTF-8 matching). [S1]
|
||||
- **Bracket expressions** — `[abc]`, `[^abc]`, `[a-z]`, `[A-Z]`, `[0-9]`, etc. [S1]
|
||||
- **Metacharacters** — `|`, `.`, `^`, `$`, `\d`/`\D`, `\s`/`\S`, `\w`/`\W`, `\b`, `\uxxxx`. [S1]
|
||||
- **Quantifiers** — `n+`, `n*`, `n?`, `n{3}`, `n{2,5}`, `n{3,}`. [S1]
|
||||
- **Escaping special characters** — backslash before literal special characters (e.g. `/\?+/` to match one-or-more literal `?`). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic pattern: `$exp = "/w3schools/i"; // case-insensitive search for "w3schools"`. [S1]
|
||||
- Escaping special char: `$pattern = '/\?+/'; // matches one or more literal question marks`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 패턴에 슬래시가 포함될 때 #나 ~로 구분자를 바꾸는 것이 실전에서 자주 쓰이는 관행이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Case-insensitive regex pattern (PHP):
|
||||
```php
|
||||
$exp = "/w3schools/i";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP RegEx Functions]], [[PHP Superglobals Get]], [[PHP Form Validation]]
|
||||
- **참조 맥락:** 정규표현식 문법 기초 — 정규표현식 함수(RegEx Functions) 챕터로 직접 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Regular Expressions — https://www.w3schools.com/php/php_regex.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Regular Expressions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: php-regex-functions
|
||||
title: "PHP RegEx Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["preg_match", "preg_replace", "preg_grep", "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", "regex", "functions"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_regex_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP RegEx Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`preg_match()` and `preg_match_all()` return fundamentally different numbers for the same match — `preg_match()` caps at 1 (match found) or 0 (not found), while `preg_match_all()` returns the actual COUNT of matches, meaning `preg_match()` can never tell you "how many," only "whether." [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`preg_match($pattern, $str)`** — returns 1 if found, 0 if not. [S1]
|
||||
- **`preg_match_all($pattern, $str)`** — returns the total NUMBER of matches. [S1]
|
||||
- **`preg_replace($pattern, $replacement, $str)`** — replaces all matches with a new string. [S1]
|
||||
- **`preg_split($pattern, $str)`** — splits a string into an array using regex matches as separators. [S1]
|
||||
- **`preg_grep($pattern, $array)`** — filters an array, keeping only elements matching the pattern; third argument `PREG_GREP_INVERT` flips this to keep NON-matching elements. [S1]
|
||||
- **Grouping with `( )`** — applies quantifiers to a whole sub-pattern, and captures sub-matches. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- preg_match: `$str = "Visit W3Schools"; $pattern = "/w3schools/i"; echo preg_match($pattern, $str); // 1`. [S1]
|
||||
- preg_match_all (count): `$str = "The rain in SPAIN falls mainly on the plains."; $pattern = "/ain/i"; echo preg_match_all($pattern, $str); // counts occurrences`. [S1]
|
||||
- preg_replace: `$str = "Visit Microsoft!"; $pattern = "/microsoft/i"; echo preg_replace($pattern, "W3Schools", $str);`. [S1]
|
||||
- preg_split: `$str = "This is a text"; $pattern = "/[\s:]/"; $components = preg_split($pattern, $str); print_r($components);`. [S1]
|
||||
- preg_grep (filter matching): `$input = ["Red", "Pink", "Green", "Blue", "Purple"]; $result = preg_grep("/^p/i", $input); // Pink, Purple`. [S1]
|
||||
- preg_grep inverted (filter non-matching): `$result = preg_grep("/^p/i", $input, PREG_GREP_INVERT); // Red, Green, Blue`. [S1]
|
||||
- Grouping: `$str = "Apples and bananas."; $pattern = "/ba(na){2}/i"; echo preg_match($pattern, $str); // matches "banana" pattern: ba + (na)x2`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **preg_match와 preg_match_all의 반환값 차이**: 전자는 0/1(존재 여부)만 반환하지만 후자는 실제 매치 개수를 반환한다는 점이 핵심 구분점이다. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — preg_grep()으로 배열에서 특정 패턴에 맞는 항목만 필터링하는 것이 실전 데이터 필터링의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Filtering an array with preg_grep() (PHP):
|
||||
```php
|
||||
$input = ["Red", "Pink", "Green", "Blue", "Purple"];
|
||||
$result = preg_grep("/^p/i", $input); // items starting with "p" (case-insensitive)
|
||||
print_r($result); // Pink, Purple
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP RegEx]], [[PHP Forms]], [[PHP Form Validation]]
|
||||
- **참조 맥락:** 정규표현식 함수 활용 — 폼(Forms) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Regular Expression Functions — https://www.w3schools.com/php/php_regex_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Regular Expression Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: php-sessions
|
||||
title: "PHP Sessions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["session_start()", "$_SESSION", "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", "sessions"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_sessions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Sessions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A session's ONLY client-side footprint is a small random ID stored in a `PHPSESSID` cookie — the actual session DATA lives entirely on the server (typically in a temp file), meaning sessions are fundamentally more secure than cookies for sensitive data, since the browser never holds the real information, just a lookup key. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Session** — solves HTTP's statelessness by storing per-user data server-side, linked via a client-side ID cookie. [S1]
|
||||
- **`session_start()`** — must be called at the very beginning of every script using sessions, before ANY HTML output or whitespace. [S1]
|
||||
- **`$_SESSION`** — superglobal for storing/accessing session variables. [S1]
|
||||
- **`unset($_SESSION["key"])`** — removes one session variable. [S1]
|
||||
- **`session_unset()`** — clears ALL session variables. [S1]
|
||||
- **`session_destroy()`** — destroys all data tied to the current session entirely. [S1]
|
||||
- **Default lifetime** — session data persists until the browser closes (unlike cookies, which can have a long fixed expiration). [S1]
|
||||
- **Sessions vs. cookies** — sessions: server-stored, more secure, closes-on-browser-close, more efficient (no repeated data transfer); cookies: browser-stored, less secure, long expiration possible, less efficient (sent with every request). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Start + set variables: `session_start(); $_SESSION["favcolor"] = "green"; $_SESSION["favanimal"] = "cat";`. [S1]
|
||||
- Retrieve on another page: `session_start(); if(isset($_SESSION["favcolor"])) { echo $_SESSION["favcolor"]; }`. [S1]
|
||||
- Modify: overwrite directly — `$_SESSION["favcolor"] = "yellow";`. [S1]
|
||||
- Destroy (logout): `session_start(); session_unset(); session_destroy(); echo "You have been logged out.";`. [S1]
|
||||
- Debug all values: `print_r($_SESSION);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — session_unset()+session_destroy() 조합으로 로그아웃을 구현하는 것이 실전 인증 시스템의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Logging out by clearing all session data (PHP):
|
||||
```php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
echo "You have been logged out.";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Cookies]], [[PHP Filter]]
|
||||
- **참조 맥락:** 서버 측 사용자 데이터 저장 — 필터(Filter) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Sessions — https://www.w3schools.com/php/php_sessions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Sessions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-string-concatenate
|
||||
title: "PHP String Concatenate"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: [". operator", "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", "strings", "concatenation"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_string_concatenate.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP String Concatenate]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP's concatenation operator is `.` (a period), NOT `+` like many other languages — this is a common source of confusion for developers coming from JavaScript or Python, and joining two strings with `.` produces zero implicit spacing (`"Hello" . "World"` gives "HelloWorld", not "Hello World"). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`.` operator** — concatenates (joins) two strings. [S1]
|
||||
- **No implicit spacing** — `$x . $y` gives no space between values; must explicitly add `" "`. [S1]
|
||||
- **Double-quote interpolation as an alternative** — `"$x $y"` embeds both variables with a literal space, avoiding the `.` operator entirely. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic concat (no space): `$x = "Hello"; $y = "World"; $z = $x . $y; echo $z; // "HelloWorld"`. [S1]
|
||||
- With explicit space: `$z = $x . " " . $y; echo $z; // "Hello World"`. [S1]
|
||||
- Interpolation alternative: `$z = "$x $y"; echo $z; // "Hello World"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 큰따옴표 보간을 활용해 . 연산자 없이 두 변수를 결합하는 방식이 더 간결한 대안으로 제시된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Concatenation with explicit space vs. double-quote interpolation (PHP):
|
||||
```php
|
||||
$x = "Hello";
|
||||
$y = "World";
|
||||
$z = $x . " " . $y; // "Hello World" via . operator
|
||||
$z2 = "$x $y"; // "Hello World" via interpolation
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Strings]], [[PHP String Modify]], [[PHP String Slicing]]
|
||||
- **참조 맥락:** 문자열 결합 연산자 — 슬라이싱(Slicing) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - Concatenate Strings — https://www.w3schools.com/php/php_string_concatenate.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - Concatenate Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: php-string-escape
|
||||
title: "PHP String Escape"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["escape characters", "PHP 이스케이프 문자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["php", "programming", "w3schools", "strings", "escape"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_string_escape.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP String Escape]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PHP has an escape sequence specifically for the `$` sign (`\$`) — a character other languages rarely need to escape — because `$` triggers variable interpolation inside double-quoted strings, so writing a literal dollar sign next to what could be mistaken for a variable name requires this PHP-specific escape. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Escape character** — a backslash `\` followed by the character to insert literally. [S1]
|
||||
- **Why needed** — inserting characters that would otherwise be interpreted specially (e.g., a `"` inside a double-quoted string). [S1]
|
||||
- **Escape table** — `\'` (single quote), `\"` (double quote), `\$` (literal PHP variable sigil), `\n` (newline), `\r` (carriage return), `\t` (tab), `\f` (form feed), `\ooo` (octal), `\xhh` (hex). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Problem: `$x = "We are the so-called "Vikings" from the north."; // illegal — breaks the string`. [S1]
|
||||
- Fix: `$x = "We are the so-called \"Vikings\" from the north."; echo $x;`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 큰따옴표 문자열 안에 인용구를 포함해야 할 때 \"로 이스케이프하는 것이 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Escaping double quotes inside a double-quoted string (PHP):
|
||||
```php
|
||||
$x = "We are the so-called \"Vikings\" from the north.";
|
||||
echo $x;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Strings]], [[PHP String Slicing]], [[PHP Numbers]]
|
||||
- **참조 맥락:** 문자열 섹션의 마지막 — 숫자(Numbers) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - Escape Characters — https://www.w3schools.com/php/php_string_escape.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - Escape Characters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: php-string-functions
|
||||
title: "PHP String Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["strlen", "strpos", "str_contains", "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", "strings", "functions"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_string_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP String Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`str_contains()`, `str_starts_with()`, and `str_ends_with()` are ALL PHP 8.0+ only — the source explicitly flags this version dependency for each, meaning code targeting older PHP must fall back to `strpos()` for containment checks, a compatibility gap worth checking before using these convenience functions. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`strlen()`** — returns string length. [S1]
|
||||
- **`str_word_count()`** — counts words in a string. [S1]
|
||||
- **`str_contains()`** (PHP 8.0+) — boolean substring check, case-sensitive. [S1]
|
||||
- **`strpos()`** — returns the position of the first match, or `false` if not found; case-sensitive; index starts at 0. [S1]
|
||||
- **`str_starts_with()`** / **`str_ends_with()`** (PHP 8.0+) — boolean prefix/suffix checks, case-sensitive. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Length: `echo strlen("Hello world!");`. [S1]
|
||||
- Word count: `echo str_word_count("Hello world!");`. [S1]
|
||||
- Contains (case-sensitive): `$txt = "I really love PHP!"; var_dump(str_contains($txt, "love")); // true; var_dump(str_contains($txt, "Love")); // false`. [S1]
|
||||
- Position search: `echo strpos("Hello world!", "world"); // 6`. [S1]
|
||||
- Starts/ends with (case-sensitive): `var_dump(str_starts_with($txt, "I really")); // true; var_dump(str_starts_with($txt, "i really")); // false`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **PHP 8.0 이상 전용 함수**: str_contains/str_starts_with/str_ends_with 모두 PHP 8.0부터 사용 가능하며, 구버전에서는 strpos()로 대체해야 함이 각각 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 문자열 포함 여부 검사가 사용자 입력 검증 등에서 자주 쓰이는 실전 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Case-sensitive substring check (PHP 8.0+):
|
||||
```php
|
||||
$txt = "I really love PHP!";
|
||||
var_dump(str_contains($txt, "love")); // true
|
||||
var_dump(str_contains($txt, "Love")); // false (case-sensitive)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP Strings]], [[PHP String Modify]], [[PHP String Slicing]]
|
||||
- **참조 맥락:** 문자열 검색/검사 함수 — 문자열 변형(Modify) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP String Functions — https://www.w3schools.com/php/php_string_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP String Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: php-string-modify
|
||||
title: "PHP String Modify"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["strtoupper", "str_replace", "explode", "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", "strings", "modify"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_string_modify.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP String Modify]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`explode()`'s separator parameter is REQUIRED, not optional — unlike some split functions in other languages that default to whitespace, PHP's `explode()` always demands you specify exactly what to split on, making the split behavior fully explicit every time. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`strtoupper()` / `strtolower()`** — case conversion. [S1]
|
||||
- **`str_replace(search, replace, subject)`** — substring replacement. [S1]
|
||||
- **`strrev()`** — reverses a string. [S1]
|
||||
- **`trim()`** — removes leading/trailing whitespace. [S1]
|
||||
- **`explode(separator, string)`** — splits a string into an array by a required separator. [S1]
|
||||
- **`print_r()`** — displays array contents in a readable format. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Case conversion: `strtoupper($x); strtolower($x);`. [S1]
|
||||
- Replace: `echo str_replace("World", "Dolly", $x); // "Hello Dolly!"`. [S1]
|
||||
- Reverse: `echo strrev($x);`. [S1]
|
||||
- Trim: `$x = " Hello World! "; echo trim($x);`. [S1]
|
||||
- Explode with required separator: `$x = "Hello lovely World!"; $y = explode(" ", $x); print_r($y); // ["Hello", "lovely", "World!"]`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **explode() 구분자 필수**: 분리자를 생략할 수 없고 반드시 지정해야 한다는 점이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 공백 기준으로 문장을 단어 배열로 나누는 explode()가 텍스트 처리의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Splitting a string into an array with explode() (PHP):
|
||||
```php
|
||||
$x = "Hello lovely World!";
|
||||
$y = explode(" ", $x);
|
||||
print_r($y); // Array ( [0] => Hello [1] => lovely [2] => World! )
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP String Functions]], [[PHP Arrays]], [[PHP String Concatenate]]
|
||||
- **참조 맥락:** 문자열 변형 함수 — explode()는 배열(Arrays) 챕터와 직접 연결됨.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - Modify Strings — https://www.w3schools.com/php/php_string_modify.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - Modify Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: php-string-slicing
|
||||
title: "PHP String Slicing"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["substr()", "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", "strings", "substr"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_string_slicing.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP String Slicing]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`substr()`'s length parameter can itself be NEGATIVE — meaning "stop N characters before the end" rather than "take N characters" — so `substr($x, 5, -3)` reads as "start at index 5, and go until you're 3 characters from the end," a dual meaning of the third parameter that requires care since negative start and negative length behave completely differently. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`substr(string, start, length)`** — extracts a substring. [S1]
|
||||
- **Positive start** — 0-indexed position to begin the slice. [S1]
|
||||
- **Omitted length** — slices to the end of the string. [S1]
|
||||
- **Negative start** — counts from the end (-1 is the last character). [S1]
|
||||
- **Negative length** — stops that many characters BEFORE the end, rather than taking that many characters. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic slice: `$x = "Hello World!"; echo substr($x, 6, 5); // "World"`. [S1]
|
||||
- To the end (no length): `echo substr($x, 6); // "World!"`. [S1]
|
||||
- Negative start: `echo substr($x, -5, 3); // "Wor" (starting from index -5)`. [S1]
|
||||
- Negative length: `$x = "Hi, how are you?"; echo substr($x, 5, -3); // "ow are y" (stop 3 chars before the end)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **음수 길이의 의미**: 길이 파라미터가 음수일 경우 "가져올 문자 수"가 아니라 "끝에서부터 생략할 문자 수"로 해석된다는 점이 예제로 명확히 검증됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 문장 끝 몇 글자를 제외한 나머지를 추출하는 것이 음수 길이 파라미터 활용의 대표 사례다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Negative length stops before the end of the string (PHP):
|
||||
```php
|
||||
$x = "Hi, how are you?";
|
||||
echo substr($x, 5, -3); // "ow are y"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP String Concatenate]], [[PHP String Escape]], [[PHP Numbers]]
|
||||
- **참조 맥락:** 문자열 일부 추출 — 이스케이프 문자(Escape) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP - Slicing Strings — https://www.w3schools.com/php/php_string_slicing.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP - Slicing Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: php-strings
|
||||
title: "PHP Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["single vs double quotes", "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", "strings", "quotes"]
|
||||
raw_sources: ["https://www.w3schools.com/php/php_string.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[PHP Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Double and single quotes are NOT interchangeable in PHP — double quotes interpolate variables and support rich escape sequences (`\n`, `\t`) at a slight performance cost, while single quotes output everything literally (even `$x` prints as `$x`, not its value) and only support `\'`/`\\`, making single quotes both faster and safer for constant strings with no variables. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Double quotes** — substitute variable values; support many escape sequences (`\n`, `\r`, `\t`, `\$`, `\"`). [S1]
|
||||
- **Single quotes** — output text literally, including `$var` syntax as-is; only `\'` and `\\` are recognized escapes. [S1]
|
||||
- **Performance** — single quotes are slightly faster (no parsing needed for variables/escapes). [S1]
|
||||
- **Readability trade-off** — double quotes avoid concatenation clutter when many variables are embedded; single quotes are cleaner for constant strings. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Variable substitution (double): `$x = "John"; echo "Hello $x"; // Hello John`. [S1]
|
||||
- No substitution (single): `$x = "John"; echo 'Hello $x'; // Hello $x`. [S1]
|
||||
- Escape sequence comparison: `echo "Hello $x\n"; echo "\tHow are you?\n";` (double, both work) vs. `echo 'Hello $x\n'; echo '\tHow are you?\n';` (single, literal output including the backslash sequences). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **작은따옴표의 리터럴 출력**: $x 같은 변수 구문조차 작은따옴표 안에서는 값으로 치환되지 않고 문자 그대로 출력된다는 점이 예제로 명확히 검증됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 변수가 많은 문자열에는 큰따옴표, 상수 문자열에는 작은따옴표를 쓰는 것이 실전 코드 스타일의 일반적 관행이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Single quotes output variables literally (PHP):
|
||||
```php
|
||||
$x = "John";
|
||||
echo "Hello $x"; // Hello John (double quotes interpolate)
|
||||
echo 'Hello $x'; // Hello $x (single quotes do not)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[PHP Tutorial]]
|
||||
- **관련 개념:** [[PHP String Functions]], [[PHP String Concatenate]], [[PHP String Escape]]
|
||||
- **참조 맥락:** 문자열 기초(따옴표 차이) — 문자열 함수 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — PHP Strings — https://www.w3schools.com/php/php_string.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "PHP Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user