#50381 [Opn->Csd]: Error in version_compare() example

From: Date: Mon, 07 Dec 2009 14:48:23 +0000
Subject: #50381 [Opn->Csd]: Error in version_compare() example
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3413@lists.php.net to get a copy of this message
ID: 50381 Updated by: rquadling@php.net Reported By: a dot schilder at gmx dot de -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Irrelevant PHP Version: Irrelevant New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2009-12-07 14:48:09] svn@php.net Automatic comment from SVN on behalf of rquadling Revision: http://svn.php.net/viewvc/?view=revision&revision=291819 Log: Example fixed. Fix #50381 ------------------------------------------------------------------------ [2009-12-04 10:19:52] a dot schilder at gmx dot de Description: ------------ The first two examples for version_compare() are wrong - the code does not match the printed text ("at least" although the check matches greater versions). Reproduce code: --------------- --- From manual page: function.version-compare --- <?php if (version_compare(PHP_VERSION, '6.0.0') === 1) { echo 'I am at least PHP version 6.0.0, my version: ' . PHP_VERSION . "\n"; } if (version_compare(PHP_VERSION, '5.3.0') === 1) { echo 'I am at least PHP version 5.3.0, my version: ' . PHP_VERSION . "\n"; } ?> Expected result: ---------------- <?php if (version_compare(PHP_VERSION, '6.0.0') >= 0) { echo 'I am at least PHP version 6.0.0, my version: ' . PHP_VERSION . "\n"; } if (version_compare(PHP_VERSION, '5.3.0') >= 0) { echo 'I am at least PHP version 5.3.0, my version: ' . PHP_VERSION . "\n"; } ?> OR <?php if (version_compare(PHP_VERSION, '6.0.0') === 1) { echo 'I am greater PHP version 6.0.0, my version: ' . PHP_VERSION . "\n"; } if (version_compare(PHP_VERSION, '5.3.0') === 1) { echo 'I am greater PHP version 5.3.0, my version: ' . PHP_VERSION . "\n"; } ?> OR BOTH... Actual result: -------------- PHP 5.3.0: (no output) PHP 5.3.1: I am at least PHP version 5.3.0, my version: 5.3.1 PHP 6.0.0: I am at least PHP version 5.3.0, my version: 6.0.0 PHP 6.0.1: I am at least PHP version 6.0.0, my version: 6.0.1 I am at least PHP version 5.3.0, my version: 6.0.1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50381&edit=1

« previous php.doc.bugs (#3413) next »