I'm having problems getting version_compare to work. I have a constant (IZ_MINVER) and a variable ($_SESSION['backupmeta']['izver']). 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? 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. } Code (markup): Produces the output '2.8.8:2.8.8 :true'. But it should return 0, since they're equal.
This had been illuding me for ages, then someone on IRC suggested trimming the strings. One of them must have had an escape or a line break on the end. Thanks for the help.