--- 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 . "
"; }`. [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).