For Loop in PHP in Hindi – PHP For Loop In Hindi:- For Loop Ka Istemal Tab Tak Hota Hain Jab Tak Kisi condition Ka Satisfaction Nhi Hota Hai Tab Tak For Loop Ka statement repeat Hota Rahta Hai |
PHP Loops 4 Type Ke Hote Hai |
- While loop
- Do-while loop
- For loop
- Foreach loop
PHP For Loop In Hindi
Friends Agar Me Aapse Kahu Ki MasterPrograming ko 10 bar Print Karana Hai to Aap Kiya Karenge | Mere Hisab Se Aap For Loop in Hindi Ka Hi Istemal Karenge Kyoki Aap Bar Bar cout se Print Nhi Kara Sakte Hai | Kyoki Ye acche Programmer ki Pahchan Nhi Hoti Hai |
Isliye Ham For Loop Or While Loop Ka Istemal Karte Hain Program To Easy Karne Ke Liye |
Syntax
for (init Var ; test Condition; increment or Decrement) { code to be executed for each iteration; }
Example:
<?php for ($x = 1; $x <= 10; $x++) { echo "MasterPrograming <br>"; } ?>
- $x = 1; – Initialize the loop counter ($x), and set the start value to 1
- $x <= 10; – Continue the loop as long as $x is less than or equal to 10
- $x++ – Increase the loop counter value by 1 for each iteration
Output:
Masterprograming Masterprograming Masterprograming Masterprograming Masterprograming Masterprograming Masterprograming Masterprograming Masterprograming Masterprograming
Example 2:
<?php for ($x = 0; $x <= 10; $x++) { echo "The number is: $x <br>"; } ?>
Output:
The number is: 1 The number is: 2 The number is: 3 The number is: 4 The number is: 5 The number is: 6 The number is: 7 The number is: 8 The number is: 9 The number is: 10