PDA

View Full Version : PHP conditional for vBulletin version?


HMBeaty
08-08-2011, 01:48 AM
Is there one? Haven't exactly searched/looked through any files for this, but is there a PHP conditional for what version of vBulletin you're on?

For example:

if ($vbversion[4.1.4])
{
do this
}
If ($vbversion[4.1.3])
{
do this
}

Boofo
08-08-2011, 02:13 AM
Paul M does that in a couple of his mods I think. ;)

HMBeaty
08-08-2011, 02:15 AM
Hmm....never even noticed lol. I'll go have a look :)

kh99
08-08-2011, 02:39 AM
There's a PHP function version_compare() for doing compares on version strings: http://us2.php.net/manual/en/function.version-compare.php and the vbulletin version is in $vbulletin->versionnumber, so you could do something like

if (version_compare(@$vbulletin->versionnumber, '4.1.4', '>='))
{
...
}


An example I found in the vb code had the '@' there, I'm not sure why, I guess it would suppress an error message if $vbulletin->versionnumber didn't exist but I don't know if or when that would happen.

HMBeaty
08-08-2011, 02:41 AM
There's a PHP function version_compare() for doing compares on version strings: http://us2.php.net/manual/en/function.version-compare.php and the vbulletin version is in $vbulletin->versionnumber, so you could do something like

if (version_compare(@$vbulletin->versionnumber, '4.1.4', '>='))
{
...
}
An example I found in the vb code had the '@' there, I'm not sure why, I guess it would suppress an error message if $vbulletin->versionnumber didn't exist but I don't know if or when that would happen.
Thanks. I'll try that

Badshah93
08-08-2011, 03:58 AM
Try This

if ($vbulletin->versionnumber < "4.1.3") {

//Your Code

}