vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   PHP conditional for vBulletin version? (https://vborg.vbsupport.ru/showthread.php?t=268150)

HMBeaty 08-08-2011 12:48 AM

PHP conditional for vBulletin version?
 
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:
PHP Code:

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



Boofo 08-08-2011 01:13 AM

Paul M does that in a couple of his mods I think. ;)

HMBeaty 08-08-2011 01:15 AM

Hmm....never even noticed lol. I'll go have a look :)

kh99 08-08-2011 01:39 AM

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

PHP Code:

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 01:41 AM

Quote:

Originally Posted by kh99 (Post 2230738)
There's a PHP function version_compare() for doing compares on version strings: http://us2.php.net/manual/en/functio...on-compare.php and the vbulletin version is in $vbulletin->versionnumber, so you could do something like

PHP Code:

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 02:58 AM

Try This

Code:

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

//Your Code

}



All times are GMT. The time now is 11:46 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01659 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete