|
本帖最后由 24haoche 于 2013-12-10 10:55 编辑
<?php
class Test extends CAR_Controller{
private $used_id;
public function a(){
$this->usedr_id='aaaaa';
echo $this->used_id;
}
public function b(){
$c=$this->usedcar_id;
echo $c;
}
public function c(){
$this->a();
$c=$this->usedcar_id;
echo $c;
}
}
?>
http://localhost/index.php/test/a结果为aaaaa
http://localhost/index.php/test/c结果为aaaaa
浏览器查看http://localhost/index.php/test/a 然后查看 http://localhost/index.php/test/b没有输出结果
先执行a函数已经对$used_id付过值了,b函数再输出$used_id值,为什么不输出呢?必须如c函数一样调用a一次才可以输出。
|
|