|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-06-18 12:20 UTC] cmb@php.net
-Status: Open
+Status: Verified
-Package: Documentation problem
+Package: PHP options/info functions
[2018-06-18 12:20 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 22:00:01 2025 UTC |
Description: ------------ I'm not 100% sure if this is a documentation problem or a code problem but the documentation doesn't quite match the behavior so one of them is wrong. Since the function behavior isn't clearly wrong I'm going with doc. On "version_compare" it says: "Then it compares the parts starting from left to right. If a part contains special version strings these are handled in the following order: any string not found in this list < dev < alpha = a < beta = b < RC = rc < # < pl = p." If there is a space in the version string this gets incorporated into the "special string" and thus the string will always fall under "any string not found in this list" even if it appears to match. You can work this out from the transformations described but it's *not* intuitive and should be explicitly called out (or the function behavior changed to handle spaces) Test script: --------------- //these will all return "equal" results which is not what is immediately expected var_dump(version_compare('1.0.0 alpha 1', '1.0.0 beta 1')); var_dump(version_compare('1.0.0 dev 1', '1.0.0 beta 1')); var_dump(version_compare('1.0.0 totalgarbage 1', '1.0.0 beta 1'));