Message: Only variable references should be returned by reference In Codeigniter

Message: Only variable references should be returned by reference In Codeigniter

By Yashwant Chavan, Views 2573, Date 07-Jan-2016

Recently I have upgraded my local XAMPP to its latest version, which is causing below issue in my existing PHP Codeigniter projects. I am using PHP Version 5.6.15 and its compatible apache version (Apache/2.4.17) .

tags codeigniter

CodeIgniter Errors Filename: core/Common.php Line Number: 257

A PHP Error was encountered
Severity: Notice
Message: Only variable references should be returned by reference
Filename: core/Common.php
Line Number: 257

core/Common.php

Last line is causing the issue. return $_config[0] =& $config;

if (!function_exists('get_config')) {
    function & get;
    _config($replace = array()) {
        static $_config;

        if (isset($_config)) {
            return $_config[0];
        }

        // Is the config file in the environment folder?
        if (!defined('ENVIRONMENT') OR!file_exists($file_path = APPPATH.
                'config/'.ENVIRONMENT.
                '/config.php')) {
            $file_path = APPPATH.
            'config/config.php';
        }

        // Fetch the config file
        if (!file_exists($file_path)) {
            exit('The configuration file does not exist.');
        }

        require($file_path);

        // Does the $config array exist in the file?
        if (!isset($config) OR!is_array($config)) {
            exit('Your config file does not appear to be formatted correctly.');
        }

        // Are any values being dynamically replaced?
        if (count($replace) > 0) {
            foreach($replace as $key => $val) {
                if (isset($config[$key])) {
                    $config[$key] = $val;
                }
            }
        }

        return $_config[0] = & $config;
    }
}

Solution

Here is the github reference link which mention the above issue. To fix this you have use latest version of codeigniter CI3.0 or you have to manually fix this issue. Just replace below code with return statement. It will solve the issue.

$_config[0] =& $config; return $_config[0];
Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]