![]() |
Weird PHP variable behaviour
Here's the problem.
PHP Code:
Thanks. - Dan |
might it be that it has something to do with the regional settings, meaning that he used to interpret the dot (.) as a character, making it not a valid integer, but now interprets it as the kind of dot between the number and the decimal digits (which would mean it's a valid integer)
|
No that's not it. The region hasn't changed.
123.123 does not equal intval(123.123) because intval(123.123) equals 123 so it's doing that much correctly. What it's not doing is Echoing the 0. |
Another example of broken code from this behaviour is the vB 2.2.x update threads routine in /admin/misc.php if there are no attachments for a particular thread,
$attachsum= instead of $attachsum=0 |
actually == should return a boolean value, ie true or false and not 1 or 0.
|
Thanks Xenon.
That's fair enough but if you try it yourself, you'll see that you get an output of 1 when it's true. What about the 2nd example? |
Hmm, very wierd, maybe they choosed a behaviour like that to make it easier in comparisons.
so 1 will be true in every condition, and false will have an empty string as output, so it will always result in a false. actually to get the 0-1 way, just use intval($val==intval($val)); that should return what you want. edit: vb2.2 isn't compatible to the newest default settings of php, as php doesn't interpolate that much as php4 does. so you need a better coding to run things in php5. Some settings can be set so it acts like php4 in a lot of ways, but not on every aspect i think. |
Quote:
|
Quote:
Quote:
|
just as i expected..
|
All times are GMT. The time now is 11:04 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|