--- 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).