Jump to content

[SOLVED] ($string != 0) evaluates to false? Why?


Laogeodritt

Recommended Posts

Hello,

 

I recently encountered what seems to me as an odd behaviour in one of my scripts. Although I've quite easily fixed the problem, I can't figure this behaviour out at all, which is contrary to what I'd expect; I'd like to understand the reason behind it.

 

For a non-empty, non-numeric string $var, the expression ($var != 0) seems to always evaluate to FALSE. I would have expected any non-empty non-zero string to cause this expression to evaluate to TRUE. Can anyone explain why PHP evaluates this expression like this?

 

Thanks,

Laogeodritt

Link to comment
https://forums.phpfreaks.com/topic/116334-solved-string-0-evaluates-to-false-why/
Share on other sites

Archived

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

×
×
  • Create New...

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.