#49854 [Opn->Csd]: function.phpversion: bad code in manual example

From: Date: Thu, 15 Oct 2009 16:44:00 +0000
Subject: #49854 [Opn->Csd]: function.phpversion: bad code in manual example
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2951@lists.php.net to get a copy of this message
ID: 49854 Updated by: danbrown@php.net Reported By: clancyhood at gmail dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Mac 10.5.2 PHP Version: 5.3.0 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. Although PHP4 is not - and will never again be - officially supported, as it's been past its end-of-life for two years, the issue you reported would also exist for any version with two or more digits in any position. As a result, it's been updated to use explode() (though not list(), as you'll see when the sources update). However, while it may not be explicitly stated on the notes page, there is a level of common sense assumed - perhaps an error on our part - that those intelligent enough to engineer code will also be able to ascertain that a bug in documentation is, indeed, a bug. The following line is in warning of this exact issue when submitting a user note: "Bugs. Instead [report a bug] for this manual page to the bug database." The [report a bug] string then links directly to this URL: http://bugs.php.net/report.php? bug_type=Documentation+problem&manpage=function.phpversion By the above, it should be trivial to discover under which category the bug will be reported, and we hope that this will help you to not waste your time in the future, and so also assist in the wild-guessing about how we presently operate the websites. Thank you very much for your report, and as stated, the changes will appear in the next documentation build. Previous Comments: ------------------------------------------------------------------------ [2009-10-15 16:09:39] svn@php.net Automatic comment from SVN on behalf of danbrown Revision: http://svn.php.net/viewvc/?view=revision&revision=289673 Log: Addresses Bug #49854. ------------------------------------------------------------------------ [2009-10-13 00:01:22] clancyhood at gmail dot com 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 this bug report at http://bugs.php.net/?id=49854&edit=1

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