Jump to content
Sign in to follow this  
jaberwacky

[solved] Why are these different?

Recommended Posts

jaberwacky

If "04" == 4 Then
 MsgBox(0, '==', "TRUE")
Else
 MsgBox(0, '==', "FALSE")
EndIf

If "04" = 4 Then
 MsgBox(0, '=', "TRUE")
Else
 MsgBox(0, '=', "FALSE")
EndIf

These give different results. Will someone tell me why?

"04" is a string and 4 is an integer.

A string is an array of chars, right?

'=' is the assignment operator and '==' is the equality operator.

When I state "04" = 4, then am I not using the assigment operator?

And if so then how am I assigning 4 into "04".

Unless:

Global $string = "04" ; $string stores "04"

MsgBox(0, '', $string)

"04" = 4

MsgBox(0, '', $string) ; now $string stores the char '4'?

Ok, no that isn't it...

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites
jaberwacky

I originally posted my question there but they told me that I was actually talking about something slightly different, and so I posted a new thread. If I can find my answer there then I will delete this thread (or ask it to be deleted).

Share this post


Link to post
Share on other sites
jaberwacky

I originally posted my question there but they told me that I was actually talking about something slightly different, and so I posted a new thread. If I can find my answer there then I will delete this thread (or ask it to be deleted).

Oh duh, I totally overlooked the answer.

Share this post


Link to post
Share on other sites
jaberwacky

I dusted off my dusty, rusty helpfile:

'==' Tests if two strings are equal. Case sensitive. The left and right values are converted to strings if they are not strings already. This operator should only be used for string comparisons that need to be case sensitive.

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.