--- 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
"; }`. [S1] - Counting down: `for ($x = 10; $x >= 0; $x--) { echo "The number is: $x
"; }`. [S1] - Break: `for ($x = 0; $x <= 10; $x++) { if ($x == 3) break; echo "The number is: $x
"; }`. [S1] - Continue: `for ($x = 0; $x <= 10; $x++) { if ($x == 3) continue; echo "The number is: $x
"; }`. [S1] - Step 10: `for ($x = 0; $x <= 100; $x += 10) { echo "The number is: $x
"; }`. [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
"; } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** 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).