Welcome Guest, Not a member yet? Register   Sign In
Newbie question - global variable in codeigniter

[eluser]Đỗ Thanh Tùng[/eluser]
Hi all, I'm a newbie. I have a problem when using variable in CodeIgniter.
I have a class like this :
Class abc Extends Controller {
    function abc () {
    function a () {
        $this->something = 'something';
    function b () {
        echo $this->something;
when I run the function b like this : localhost/index.php/abc/a then localhost/index.php/abc/b
It return empty. How can I reuse the variable without send it's param again ?
Thanks for help.

[eluser]Đỗ Thanh Tùng[/eluser]
Can anybody show me how to use a global variable that I can use in both function a and b ?

[eluser]Đỗ Thanh Tùng[/eluser]
I need something like this
Need a real example.

[eluser]Pascal Kriete[/eluser]
The variable is only set for one request. Have you looked into using sessions?

[eluser]Đỗ Thanh Tùng[/eluser]
Thanks inparo.
I think using session is not the correct way but that is the simplest way can fix my problem now.
Thanks a lot.

Global variable Declaration..
declare it in config file : location.... system/application/config/config.php

$config['site_name'] =   'XXXXXXXXXXXXXXXXXXXX';

get anywhere like this....



Theme © iAndrew 2016 - Forum software by © MyBB