Welcome Guest, Not a member yet? Register   Sign In
HELP! Prolbem of global variable
#1

[eluser]Unknown[/eluser]
I'm a beginner of CI, I declare a globals variable in controller like this

<?php
$aaa='0';

class Test extends CI_Controller {

function __construct()
{
parent::__construct();

}

...

then i change this global variable in one of the functions in this controller

$GLOBALS['aaa']=$this->input->post('bbb');

in this function, i have checked the 'aaa' and the content of it has been changed to the value of 'bbb' which is input by the user.

But when i use 'aaa' in other function, the value is unchanged, it is still 0 as initialized. what can i do if I want to use the new value of it? Pls give some helps, thx~
#2

[eluser]InsiteFX[/eluser]
Maybe if you move it into the class it will work!
#3

[eluser]Aken[/eluser]
I suggest you learn more about variable scopes, class properties, and other basic PHP items before venturing into CodeIgniter. Otherwise you're setting yourself up to do a lot of poor coding.




Theme © iAndrew 2016 - Forum software by © MyBB