245

Quick question.

Is there something similar to a phpinfo() - that would display the version for CodeIgniter?

Thanks.

Colin Brock
  • 21,267
  • 9
  • 46
  • 61
Dirk
  • 6,774
  • 14
  • 51
  • 73

7 Answers7

370

Yes, the constant CI_VERSION will give you the current CodeIgniter version number. It's defined in: /system/codeigniter/CodeIgniter.php As of CodeIgniter 2, it's defined in /system/core/CodeIgniter.php

For example,

echo CI_VERSION; // echoes something like 1.7.1
Colin Brock
  • 21,267
  • 9
  • 46
  • 61
  • 5
    Correct. It's also in the commments of that file though, so no need to write or run code just to find out the version. – Fer Feb 11 '10 at 14:20
  • 10
    In newer versions CodeIgniter.php is located in /system/core folder. – z-boss Jul 14 '11 at 03:08
  • 3
    @downvoter: Why the recent downvote on this answer? Is something incorrect? – Colin Brock May 11 '12 at 11:05
  • Downvote because @Timo's answer is much more precise and this answer does not make any sense; why use a function to *echo* a constant when one could either just use the constant or echo it from a view or whereever it is needed? – Thomas Daugaard Jun 11 '14 at 13:21
  • 6
    @ThomasDaugaard: A downvote implies the answer is not helpful. While I agree that the `get_version` wrapper is superfluous, the fact that I pointed out that this constant exists does answer the question and, I would argue, *is* helpful. Your point is taken, however, and I've edited to remove the `get_version` wrapper. Thanks for the feedback. – Colin Brock Jun 12 '14 at 00:44
  • @ThomasDaugaard yea, this is the best answer i think. no need to be downvoted – Yoshioka Feb 06 '16 at 08:28
  • If you are in linux, go to the directory where code igniter is installed and use the command `grep -ir "ci_version" ./` – kaushik Apr 03 '20 at 07:59
125

Look for define in system/core/CodeIgniter.php:

define('CI_VERSION', '3.1.8');
Timo
  • 2,922
  • 3
  • 29
  • 28
  • 6
    Not sure why this isn't the accepted and popular answer. Who wants to run a php file/function to get it to spit out what's written right there? – Tyler Collier Jan 10 '14 at 00:17
  • 8
    @TylerCollier Because thats what the question is, It asks if there is an option to spit out? I bet you read the question again before posting. – Clain Dsilva Mar 04 '15 at 04:30
  • 3
    You're right! I didn't think of 'spit out' in that sense, but I'm sure some people want to get to it programmatically. – Tyler Collier Mar 04 '15 at 15:44
  • You can find the file using 'locate CodeIgniter.php' and then cat file | grep -i version – Philippe Delteil Apr 25 '19 at 19:40
  • 1
    In Codeigniter 4, the CI_VERSION is defined in `system/CodeIgniter.php`. Look for it in `vendor/codeigniter4/framework/…` – nJGL May 20 '20 at 09:00
15

You should try :

<?php
echo CI_VERSION;
?>

Or check the file system/core/CodeIgniter.php

Sebastianb
  • 2,020
  • 22
  • 31
Anish Rai
  • 698
  • 9
  • 16
6

you can easily find the current CodeIgniter version by

echo CI_VERSION 


or you can navigate to System->core->codeigniter.php file and you can see the constant

/**
 * CodeIgniter Version
 *
 * @var string
 *
 */
    const CI_VERSION = '3.1.6';


Kishor Pant
  • 136
  • 1
  • 4
5

From a controller or view - use the following to display the version:

<?php
   echo CI_VERSION;
?>
Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
4

Please check the file "system/core/CodeIgniter.php". It is defined in const CI_VERSION = '3.1.10';

Nil Llisterri
  • 787
  • 7
  • 19
Nooha Haris
  • 41
  • 1
  • 4
2

For CodeIgniter 4, use the following:

<?php    
    echo \CodeIgniter\CodeIgniter::CI_VERSION;
?>