[Typo3-dev] version checking within extensions

Martin T. Kutschker Martin.T.Kutschker at blackbox.net
Thu Mar 18 15:13:12 CET 2004


S. Teuber wrote:
> Hey Masi,
> 
>> t3lib/config_default.php:
>>
>> $TYPO_VERSION = '3.6.0RC1';
>>
>> Could we have also?
>>
>> $TYPO_VERSION_MAJOR = 3;
>> $TYPO_VERSION_MINOR = 6;
>> $TYPO_VERSION_WHATSTHELASTNUMBERCALLED = 0;
>> $TYPO_VERSION_INFO = 'RC1';
> 
> 
> As a workaround, why don't you split the version by dots?
> list($major, $minor, $whatever) = explode('.', $TYPO_VERSION);

Well, there is also t3lib::int_from_ver() which helps a bit. But it 
cannot cope with trailing strings like "RC1".

Here's an alternative version:

function int_from_ver($verNumberStr)    {
  if (ereg('\d+)\.(\d+)\.(\d+)',$verNumberStr,$verParts)) {
   return 
intval(sprintf('%d%03d%03d',$verParts[1],$verParts[2],$verParts[3]));
  }
  return 0;
}

It simply ignores anything before or after the version itself.

Masi





More information about the TYPO3-dev mailing list