Welcome Guest, Not a member yet? Register   Sign In
Whats the best practice of sharing common variable among functions of a class
#1

[eluser]Sumon[/eluser]
[EDITED: DAMM!!! IGNORE this post. it's 100% perfect & Sorry for my STUPID post]
here is my controller
Code:
class Clients extends Controller {
function __construct(){
  parent::Controller();
  $uri_array = $this->uri->uri_to_assoc(1);
  $this->folder_id = $uri_array['folder']; //This not works
  $this->session->set_userdata("folder_id",$uri_array['folder']);
}

public function overview() {
  $folder_id = $this->folder_id; //ERROR: Message: Undefined property: Clients::$folder_id
  $folder_id = $this->session->userdata('folder_id');
}
}

By example the url is http://www.shopno-dinga.com/client/overview/folder/420

when i use session to share folder_id[$folder_id = $this->session->userdata('folder_id')] among functions it works. but seems to me $this->folder_id is the best approach. But is it possible($folder_id = $this->folder_idWink ?

what's the best practice ?




Theme © iAndrew 2016 - Forum software by © MyBB