|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-10-15 16:09 UTC] svn@php.net
[2009-10-15 16:43 UTC] danbrown@php.net
[2009-10-15 16:56 UTC] clancyhood at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 01:00:01 2026 UTC |
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