#50381 [NEW]: Error in version_compare() example
| From: | a dot schilder at gmx dot de | Date: | Fri, 04 Dec 2009 10:19:52 +0000 |
| Subject: | #50381 [NEW]: Error in version_compare() example | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-3406@lists.php.net to get a copy of this message | ||
From: a dot schilder at gmx dot de
Operating system: Irrelevant
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: Error in version_compare() example
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 bug report at http://bugs.php.net/?id=50381&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50381&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50381&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50381&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50381&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50381&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50381&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50381&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50381&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50381&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50381&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50381&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50381&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50381&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50381&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50381&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50381&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50381&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50381&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50381&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50381&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50381&r=mysqlcfg