| Aush |
Mar 24 2012, 07:37 PM
Post
#1
|
|
Novice ![]() ![]() Group: Members Posts: 25 Joined: 8-February 10 Member No.: 11,027 |
I have a very small script that I need help with. I'm learning PHP, and I can't figure out why this loop won't work. Please help! =]
Here it is: <?PHP $counter = 0; $start = 1; for($start; $start < 11; $start++) { $counter = $counter++; print $counter . "<BR>"; } ?> It DOES work when I do this, however: <?PHP $counter = 0; $start = 1; for($start; $start < 11; $start++) { $counter = $counter + 1; print $counter . "<BR>"; } ?> I bolded the difference between the two. Thank you very much. |
![]() ![]() |
| Darin McGrew |
Mar 24 2012, 08:08 PM
Post
#2
|
|
WDG Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Root Admin Posts: 7,852 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
Do you understand what $counter++ does?
-------------------- Darin McGrew
WDG Member since 1998 |
Aush PHP Question - Small Script Mar 24 2012, 07:37 PM
Aush I thought it was supposed to add 1 everytime it lo... Mar 24 2012, 08:48 PM
Ephraim F. Moya
I have a very small script that I need help with.... Mar 24 2012, 09:31 PM
Aush Thank you for the response. :)
I still have a que... Mar 25 2012, 01:13 PM
Ephraim F. Moya
Thank you for the response. :)
I still have a qu... Mar 25 2012, 01:55 PM
Ephraim F. Moya
Thank you for the response. :)
I still have a q... Mar 25 2012, 10:42 PM
Darin McGrew Let's walk through what happens. We start with... Mar 25 2012, 11:29 PM![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd May 2013 - 11:31 AM |