例如,我有一个这样的类
public function data() {
$a = 1;
$b = 2;
$c = 3;
}
public function codeigniter() {
$a, $b, $b //how i can get the value??
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得的价值$a,$b,$c这样我可以在使用它codeigniter()的功能?我用codeigniter?我需要添加return;吗?
我假设这两个函数同时在classigniter和codeigniter的控制器类中
class Sample extends CI_Controller {
// declare variables
public $a;
public $b;
public $c;
public function __construct() {
// call codeigniter method
$this->codeigniter();
}
public function data() {
$this->a = 10;
$this->b = 11;
$this->c = 12;
}
public function codeigniter() {
// call method data();
$this->data();
echo $this->a; // prints 10
echo $this->b; // prints 11
echo $this->c; // prints 12
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
668 次 |
| 最近记录: |