#49854 [NEW]: function.phpversion: bad code in manual example
| From: | clancyhood at gmail dot com | Date: | Tue, 13 Oct 2009 00:01:23 +0000 |
| Subject: | #49854 [NEW]: function.phpversion: bad code in manual example | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-2930@lists.php.net to get a copy of this message | ||
From: clancyhood at gmail dot com
Operating system: Mac 10.5.2
PHP version: 5.3.0
PHP Bug Type: Documentation problem
Bug description: function.phpversion: bad code in manual example
Description:
------------
example #2 erroneously produces a version id of 40301 for version string
4.3.11 since the code $version{4} simply accesses the character at position
4 of the string without regard to the length of the release number.
The releases 4.3.1 and 4.3.11 are over a year apart. I'd suggest using
explode to seperate the version string properly.
<?php
list($major, $minor, $release) = explode('.', PHP_VERSION);
define('PHP_VERSION_ID', ($major * 10000 + $minor * 100 + $release));
?>
(BTW, it's terribly frustrating to have wasted one's time adding a note
since documentation issues are classed as "bugs". Something to this effect
on the "add note" page would have prevented me wasting my time - and so
subsequently being able to make a wild guess about how PHP.net runs its
site)
Reproduce code:
---------------
---
From manual page: function.phpversion
---
<?php
// PHP_VERSION_ID is available as of PHP 5.2.7, if our
// version is lower than that, then emulate it
if(!defined('PHP_VERSION_ID'))
{
$version = PHP_VERSION;
define('PHP_VERSION_ID', ($version{0} * 10000 + $version{2} * 100 +
$version{4}));
}
?>
Expected result:
----------------
A PHP_VERSION_ID of 40311 for PHP_VERSION 4.3.11
Actual result:
--------------
A PHP_VERSION_ID of 40301 for PHP_VERSION 4.3.11
--
Edit bug report at http://bugs.php.net/?id=49854&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49854&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49854&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49854&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49854&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49854&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49854&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49854&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49854&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49854&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49854&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49854&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49854&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49854&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49854&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49854&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49854&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49854&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49854&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49854&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49854&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49854&r=mysqlcfg