Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Version
#1

(This post was last modified: 08-05-2020, 02:22 AM by eleumas.)

Hi, for Codeigniter 3 there was
Code:
CI_VERSION
for know wich version of Codeigniter i was using. For Codegniter 4?

Thanks.
Reply
#2

This is how I do, maybe there's a shorter way, I don't know.

Within your controller use this line,

PHP Code:
$data['version'] = \CodeIgniter\CodeIgniter::CI_VERSION

And then on your view file call   $version :

PHP Code:
<?php echo $version?>
Reply
#3

(08-05-2020, 06:09 AM)demyr Wrote: This is how I do, maybe there's a shorter way, I don't know.

Within your controller use this line,

PHP Code:
$data['version'] = \CodeIgniter\CodeIgniter::CI_VERSION

And then on your view file call   $version :

PHP Code:
<?php echo $version?>

Thanks for reply!

I tried and in view you can use the follow code for print the CodeIgniter version  Smile

PHP Code:
<?php echo \CodeIgniter\CodeIgniter::CI_VERSION;?>
Reply
#4

Ha ha, the quickest shortcut ever made  Big Grin   I have no idea about why I haven't tried it so far.
Reply
#5

I created a helper for it.

PHP Code:
// -----------------------------------------------------------------------

/**
 * Add this to the top of your helper file.
 *
 * use CodeIgniter\CodeIgniter;
 *
 * USAGE:
 * <?= ciVersion();?>
 */
if ( ! function_exists('ciVersion'))
{
    
/**
     * ciVersion ()
     * -------------------------------------------------------------------
     *
     * @return string
     */
    
function ciVersion() : string
    
{
        return 
'CodeIgniter version: '.CodeIgniter::CI_VERSION;
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(08-05-2020, 09:25 AM)InsiteFX Wrote: I created a helper for it.

PHP Code:
// -----------------------------------------------------------------------

/**
 * Add this to the top of your helper file.
 *
 * use CodeIgniter\CodeIgniter;
 *
 * USAGE:
 * <?= ciVersion();?>
 */
if ( ! function_exists('ciVersion'))
{
    
/**
     * ciVersion ()
     * -------------------------------------------------------------------
     *
     * @return string
     */
    
function ciVersion() : string
    
{
        return 
'CodeIgniter version: '.CodeIgniter::CI_VERSION;
    }


Thanks for your work!  Big Grin
Reply




Theme © iAndrew 2016 - Forum software by © MyBB