4

I'm writing an add-on and need to check the current EE version from PHP. What is the best way to get the current ExpressionEngine version?

4

One option would be to use the APP_VER constant. You can see it here with a few other version constants as well:

http://ellislab.com/expressionengine/user-guide/development/constants.html#version-constants

This will give you the version number with decimals unlike Adrian's solution so, pick which route you'd like. For example:

if (APP_VER == '2.5.3')
{
   do something;
}
1
  • 1
    Ha, I just realized it was you who asked this question! And yes I will sleep a little smarter tonight knowing I knew something you didn't ;)
    – Natetronn
    Dec 16 '12 at 2:46
1

You can use $this->EE->config->item('app_version') which returns a string like 253.

I'm not sure whether this is the most reliable way to determine the version number though, or whether it's possible to get the version number including decimals.

1
  • Your way is more reliable when you use this function in the custom add-on. Because if you use the APP_VER constant in the add-on code. If user upgrade the EE version with your add-on then they will get the error of the undefined constant. May 22 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.