Bayu Angga Satrio Bayu Angga Satrio - 1 year ago 52
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

Answer Source

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'];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download