![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
if ($row['nametag'] != 0) { try |
#3
| |||
| |||
|
|
if ($row['nametag'] != 0) { Is $row['nametag'] supposed to be numeric? |
#4
| |||
| |||
|
|
On 26.09.2011 18:08, Bint wrote: if ($row['nametag'] != 0) { Is $row['nametag'] supposed to be numeric? |
#5
| |||
| |||
|
|
On 26.09.2011 18:08, Bint wrote: if ($row['nametag'] != 0) { Is $row['nametag'] supposed to be numeric? No, it's a string. If I just use If ($row['nametag']) { then it works. But it is just extremely counterintuitive that that != 0 test should fail. It is stuff like that that is always tripping me up in PHP. |
|
Thanks Bob |
#6
| |||
| |||
|
|
But it is just extremely counterintuitive that that != 0 test should fail. No, it's bad coding style. Nobody but you understands what you're trying |
#7
| |||
| |||
|
|
Bint wrote: On 26.09.2011 18:08, Bint wrote: if ($row['nametag'] != 0) { Is $row['nametag'] supposed to be numeric? No, it's a string. If I just use If ($row['nametag']) { then it works. But it is just extremely counterintuitive that that != 0 test should fail. It is stuff like that that is always tripping me up in PHP. weakly typed languages eh? where '0'=0 !!! |
#8
| |||
| |||
|
|
Bint wrote: On 26.09.2011 18:08, Bint wrote: if ($row['nametag'] != 0) { Is $row['nametag'] supposed to be numeric? No, it's a string. If I just use If ($row['nametag']) { then it works. But it is just extremely counterintuitive that that != 0 test should fail. It is stuff like that that is always tripping me up in PHP. weakly typed languages eh? where '0'=0 !!! But not even that! Where 'I am a string' == 0! I was just trying to check whether the string was NULL or not basically, and it IS counterintuitive to me at least that a string with something in it would equate to 0. |
|
Bob |
#9
| |||
| |||
|
|
Bint wrote: Bint wrote: On 26.09.2011 18:08, Bint wrote: if ($row['nametag'] != 0) { Is $row['nametag'] supposed to be numeric? No, it's a string. If I just use If ($row['nametag']) { then it works. But it is just extremely counterintuitive that that != 0 test should fail. It is stuff like that that is always tripping me up in PHP. weakly typed languages eh? where '0'=0 !!! But not even that! Where 'I am a string' == 0! I was just trying to check whether the string was NULL or not basically, and it IS counterintuitive to me at least that a string with something in it would equate to 0. I tend to use (strlen($string)==0) Or ($string == "").. |
#10
| |||
| |||
|
|
Bint wrote: Bint wrote: On 26.09.2011 18:08, Bint wrote: if ($row['nametag'] != 0) { Is $row['nametag'] supposed to be numeric? No, it's a string. If I just use If ($row['nametag']) { then it works. But it is just extremely counterintuitive that that != 0 test should fail. It is stuff like that that is always tripping me up in PHP. weakly typed languages eh? where '0'=0 !!! But not even that! Where 'I am a string' == 0! I was just trying to check whether the string was NULL or not basically, and it IS counterintuitive to me at least that a string with something in it would equate to 0. I tend to use (strlen($string)==0) Or ($string == "").. |
![]() |
| Thread Tools | |
| Display Modes | |
| |