|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-09-16 22:54 UTC] greg dot chandler at wellsfargo dot com
[2016-09-16 23:02 UTC] greg dot chandler at wellsfargo dot com
[2016-09-17 09:52 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2016-09-17 09:52 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Description: ------------ The check should be >= on numeric, and = on alpha when checking. When alphas are in the versions, the strings are not even compared. Test script: --------------- <?php Function check_versions ($compare, $against) { #### $VER_TO_COMPARE $VER_TO_COMPARE_AGAINST $bad_chars = array ( "-", "_", ".", "/", "(", ")" ); $compare = strtolower(str_replace($bad_chars, ".", $compare)); $against = strtolower(str_replace($bad_chars, ".", $against)); if ( version_compare($compare, $against, '>=') ) { echo "Current: " . $compare . " Against: " . $against . " "; return "Pass"; } else { echo "Current: " . $compare . " Against: " . $against . " "; return "Fail"; } } echo check_versions("123456abc123de78z9y0", "123456abc123de78z9y0") . "\n"; echo check_versions("123456abc123de78z9y0", "123466abc123de78z9y0") . "\n"; echo check_versions("123466abc123de78z9y0", "123466abc123de78z9y0") . "\n"; echo check_versions("123466abc123de78z9y0", "123466abd123de78z9y0") . "\n"; echo check_versions("123466abd123de78z9y0", "123466abc123de78z9y0") . "\n"; ?> Expected result: ---------------- bash-4.1$ php /tmp/data/1.php Current: 123456.abc.123.de.78.z.9.y.0 Against: 123456.abc.123.de.78.z.9.y.0 Pass Current: 123456.abc.123.de.78.z.9.y.0 Against: 123466.abc.123.de.78.z.9.y.0 Fail Current: 123466.abc.123.de.78.z.9.y.0 Against: 123466.abc.123.de.78.z.9.y.0 Pass Current: 123466.abc.123.de.78.z.9.y.0 Against: 123466.abd.123.de.78.z.9.y.0 Fail Current: 123466.abd.123.de.78.z.9.y.0 Against: 123466.abc.123.de.78.z.9.y.0 Pass Actual result: -------------- bash-4.1$ php /tmp/data/1.php Current: 123456.abc.123.de.78.z.9.y.0 Against: 123456.abc.123.de.78.z.9.y.0 Pass Current: 123456.abc.123.de.78.z.9.y.0 Against: 123466.abc.123.de.78.z.9.y.0 Fail Current: 123466.abc.123.de.78.z.9.y.0 Against: 123466.abc.123.de.78.z.9.y.0 Pass Current: 123466.abc.123.de.78.z.9.y.0 Against: 123466.abd.123.de.78.z.9.y.0 Pass Current: 123466.abd.123.de.78.z.9.y.0 Against: 123466.abc.123.de.78.z.9.y.0 Pass