Welcome Guest, Not a member yet? Register   Sign In
Global Variable?
#2

Hi,

This is not working because the controller is reinitialized on the second call.

For this to work you need to use something to keep the value of $global like session or a variable in your view.

Or returning index in your setGlobal should work.


PHP Code:
class A_Controller extends CI_Controller {

  var $global = 0;

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

  public function setGlobal($value){
    $this->global = $value;
    
$this->index();
  }

  public function index(){
    echo $this->global;
  }


A good decision is based on knowledge and not on numbers. - Plato

Reply


Messages In This Thread
Global Variable? - by Hasan Al-Haddad - 09-23-2018, 04:57 PM
RE: Global Variable? - by salain - 09-23-2018, 10:11 PM
RE: Global Variable? - by InsiteFX - 09-24-2018, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB