Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

0=='Somevalue'


kamal_sahoo

Recommended Posts

from php.net

 

If you compare an integer with a string, the string is converted to a number. If you compare two numerical strings, they are compared as integers.

 

And for the conversion:

The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero).
Link to comment
Share on other sites

Thanks, Mark.

Yes you are right.

When integer compares with string the string first converts to integer and then comparasion takes place.

But how is it possible :

'Somevalue'==0 returns true.

It compares string to integer.

Don't you think first integer converts to string and then comparasion takes place.

 

thanks in advance.

Link to comment
Share on other sites

'Somevalue'==0 returns true.

 

no, because see what it says:

If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero).

so 'somevalue' is first coverted to 0.

Link to comment
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...