Bayu Angga Satrio Bayu Angga Satrio - 3 months ago 14
PHP Question

codeigniter: how to access more than one variable of other functions in one class?

For example I have a class like this

public function data() {
$a = 1;
$b = 2;
$c = 3;

public function codeigniter() {
$a, $b, $b //how i can get the value??

How can I get the value of
so that I can use it in
function? I use codeigniter? Do I need to add a


First create a array and store the values in it and return the array.

public function data() {
    $data = array();
    return $data;

Then you can simply call the function and access the returned data.

    public function codeigniter() {
     $data_value = $this->data();

          echo $data_value['a'];
          echo $data_value['b'];
          echo $data_value['c'];