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