On 17 March 2004 17:09, Chris W. Parker wrote:
$var++ is a post incrementer meaning the value is updated at the next
command*.
* i'm not exactly sure how the compiler determines when to post
increment, but i think i'm correct.
Not quite -- the increment is performed immediately after the
Ford, Mike LSS
on Thursday, March 18, 2004 5:02 AM said:
Not quite -- the increment is performed immediately after the access
-- in fact, as part of the same operation. So:
$x = 3;
$y = ($x++ * 2) + $x;
is likely to give you $y==10, not 9.
i see. good example.
chris.
--
I have a form variable I want to increment by a value of 1 each time the
page loads. Here's what I have so far:
if(!isset($correct)) {
$correct = 0;
} else {
$correct = $correct++;
}
Seems like it should work?
Thanks!
Shane
--
PHP General Mailing List
No.
$correct++;
Is all you need for the second condition, it automatically sets itself
back.
On Wed, 2004-03-17 at 11:52, Shane McBride wrote:
I have a form variable I want to increment by a value of 1 each time the
page loads. Here's what I have so far:
if(!isset($correct)) {
No.
$correct++;
Is all you need for the second condition, it automatically sets itself
back.
Does this always work? In my timesheet app, I have to do $counter = $counter
+ 1, because for some reason the $counter++; doesn't work. It just doesn't
work, no incrementation of the variable. Is
It doesn't seem to work either way for me.
Shane
-Original Message-
From: Jake McHenry [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 17, 2004 12:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Simple: Whats wrong with this?
No.
$correct++;
Is all you need for the second
Not that I'm aware of.
In every incantation I've ever seen of the incrementing,
$correct++;
Is always, 100% equal to:
$correct = ($correct + 1);
But, maybe you ran into a case where it's not, you never know.
On Wed, 2004-03-17 at 12:00, Jake McHenry wrote:
No.
$correct++;
Is all you
This drove me nuts for a while and instead of doing $variable++ I
started using ++$variable and never had the problem again.
--Sam
Jake McHenry wrote:
No.
$correct++;
Is all you need for the second condition, it automatically sets
itself back.
Does this always work? In my
, Shane McBride wrote:
It doesn't seem to work either way for me.
Shane
-Original Message-
From: Jake McHenry [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 17, 2004 12:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Simple: Whats wrong with this?
No.
$correct++;
Is all
Hello Jake,
Wednesday, March 17, 2004, 5:00:52 PM, you wrote:
$correct++;
JM Does this always work? In my timesheet app, I have to do $counter = $counter
JM + 1, because for some reason the $counter++; doesn't work. It just doesn't
JM work, no incrementation of the variable. Is there something
Maybe you guys should take a read about pre- and post-increment :-)
Sam Masiello wrote:
This drove me nuts for a while and instead of doing $variable++ I
started using ++$variable and never had the problem again.
--Sam
Jake McHenry wrote:
No.
$correct++;
Is all you need for the second
Jake McHenry mailto:[EMAIL PROTECTED]
on Wednesday, March 17, 2004 9:01 AM said:
Does this always work? In my timesheet app, I have to do $counter =
$counter + 1, because for some reason the $counter++; doesn't work.
It just doesn't work, no incrementation of the variable. Is there
Hello Sam,
Wednesday, March 17, 2004, 5:04:21 PM, you wrote:
SM This drove me nuts for a while and instead of doing $variable++ I
SM started using ++$variable and never had the problem again.
Yes, that's a pre-increment operator. Quite different to a
post-increment. You need to use the right
++
}
Shane
-Original Message-
From: Adam Voigt [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 17, 2004 12:06 PM
To: Shane McBride
Cc: PHP
Subject: RE: [PHP] Simple: Whats wrong with this?
Well I accidentally deleted your original email, but I didn't see where
you were getting the counter
On Thursday 18 March 2004 01:07, Richard Davey wrote:
++ is a _post_ increment. This means it'll returns $correct first and
then increment it by one. There is a section in the PHP manual on this
(search for Incrementing/Decrementing Operators.
Whether it's pre or post depends on whether it is
Shane McBride mailto:[EMAIL PROTECTED]
on Wednesday, March 17, 2004 9:16 AM said:
I am just trying to get the variable to increment, than I will be
working on a session. It's basically being used to keep track of
correct/incorrect answers for an online quiz.
and so now that you've
On Wed, 2004-03-17 at 12:19, Jason Wong wrote:
On Thursday 18 March 2004 01:07, Richard Davey wrote:
++ is a _post_ increment. This means it'll returns $correct first and
then increment it by one. There is a section in the PHP manual on this
(search for Incrementing/Decrementing
No, the value still is not incrementing.
-Original Message-
From: Chris W. Parker [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 17, 2004 12:25 PM
To: Shane McBride; PHP; [EMAIL PROTECTED]
Subject: RE: [PHP] Simple: Whats wrong with this?
Shane McBride mailto:[EMAIL PROTECTED
Shane McBride mailto:[EMAIL PROTECTED]
on Wednesday, March 17, 2004 9:40 AM said:
No, the value still is not incrementing.
then you must be resetting it unknowingly or the else block in your
if..else statement is not being executed like you are expecting it to
be.
one thing i do to debug
.
Jake
- Original Message -
From: Adam Voigt [EMAIL PROTECTED]
To: Shane McBride [EMAIL PROTECTED]
Cc: PHP [EMAIL PROTECTED]
Sent: Wednesday, March 17, 2004 12:05 PM
Subject: RE: [PHP] Simple: Whats wrong with this?
Well I accidentally deleted your original email, but I didn't see
20 matches
Mail list logo