version_compare strangeness
Posted: Sun Dec 16, 2007 1:22 pm
feyd | Please use
Produces the output '2.8.8:2.8.8 :true'. But it should return 0, since they're equal.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm having problems getting version_compare to work. I have a constant ([b]IZ_MINVER[/b]) and a variable ([b]$_SESSION['backupmeta']['izver'][/b]). They're both in the format #.#.#, but version compare either always evaluates to true, or always to true, regardless of what version numbers are fed into it. I've tried so many variations, does anyone have any idea why this isn't working?Code: Select all
echo IZ_MINVER.':'.$_SESSION['backupmeta']['izver'].':'.(version_compare((string)$_SESSION['backupmeta']['izver'],(string)IZ_MINVER,"lt") ? 'true':'false');
if(version_compare((string)$_SESSION['backupmeta']['izver'],(string)IZ_MINVER,"lt")) {
// this is executed
} else {
//this should be executed, because the versions are equal.
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]