如何在codeigniter中声明全局变量?

This is my path.$t is my variable which holds the path.one time change want to reflect everywhere ??

$t="/var/www/upload/videos_comm/";

You can use the file in /application/config called constants.php. You can use that file to declare your global variable.

Or you can use define as Pankucins suggested like this:

<?php
define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
echo Constant; // outputs "Constant" and issues a notice.

define("GREETING", "Hello you.", true);
echo GREETING; // outputs "Hello you."
echo Greeting; // outputs "Hello you."

?>

The best place to declare global variable in codeigniter is the constants.php file in the directory /application/config

You can define your global variable as follows

/**
 * Custom definitions
 */
define('first_custom_variable', 'thisisit');
$yourglobalvariable = 'thisisimyglobalvariable';