Welcome Guest, Not a member yet? Register   Sign In
passing data from controller to my library [SOLVED]
#1

(This post was last modified: 10-02-2018, 02:34 AM by DELE.)

how to passing data from controller to my library? 

or

how to get uri segment(3) in library? 

my controller
Code:
$data['page'] = $this->uri->segment(3);

my library

Code:
// How to passing data from controller or uri to $page?
public function popular($page = 2){

}

Thanks before.


SOLVED

in library :
Code:
public function namefunction(){
$this->controller = $this->_CI->uri->segment(3);
}

in controller :
Code:
$data = array (
'page' => $this->uri->segment(3)
)
Reply
#2

@DELE,

Here you go: https://codeigniter.com/user_guide/gener...your-class
Reply
#3

Controller:
PHP Code:
$this->load->library('mylibrary');
$this->mylibrary->popular($this->uri->segment(3));
//or: $this->mylibrary->popular($data['page']); 
Reply
#4

solved tanks master
Reply
#5

If it is solved please explain how you solved it for other users.

Also when solved edit the title of your post and add to the end [SOLVED]
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB