a newbie parsing error

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mynmonic
New php-forum User
New php-forum User
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong
Contact:

a newbie parsing error

Postby mynmonic » Wed Dec 04, 2002 12:59 pm

inside a php scripts I have this statement:

$totalamount=$totalamount+20;

where the $totalamount was a integer value in it(not 1), but after this summing statement the $totalamount comes out with 21.

I changed the statement to :

$totalamout=$totalamount;

and the $totalamount become 1.

Can anyone tell me why this statement will turn the initial value of the variable to 1 ?

mynmonic
New php-forum User
New php-forum User
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong
Contact:

Postby mynmonic » Wed Dec 04, 2002 7:37 pm

Ok now I get more clues, when the value of $totalamount is larger than 1000, the statement '$totalamount=$totalamount' will do the wrong thing.

It works find when the value is <=1000, so the question now is, why?

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: a newbie parsing error

Postby WiZARD » Fri Dec 06, 2002 1:56 am

mynmonic wrote:inside a php scripts I have this statement:

$totalamount=$totalamount+20;

where the $totalamount was a integer value in it(not 1), but after this summing statement the $totalamount comes out with 21.

I changed the statement to :

$totalamout=$totalamount;

and the $totalamount become 1.

Can anyone tell me why this statement will turn the initial value of the variable to 1 ?

What is your's first value of $totalamount?

mynmonic
New php-forum User
New php-forum User
Posts: 18
Joined: Tue Nov 26, 2002 3:35 am
Location: Hong Kong
Contact:

Postby mynmonic » Sat Dec 07, 2002 4:57 pm

I thought it is a integer but now I noticed it is actually a string of number, since I used the number_format on it.

Just I donno why, if $totalamount=1001 and it's a string, so after '$totalamount=$totalamount' the $totalamount will be turned into 1?


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests