(Apache2 + PHP 5.2.9-2 + Codeigniter 2.1.4)
class Welcome extends CI_Controller {
public function index()
{
$CI =& get_instance();
echo $this === $CI; // echo 1
exit;
}
}
但是,
class Welcome extends CI_Controller {
public function index()
{
$this->load->library('pagination');
$CI =& get_instance();
echo $this === $CI; // echo 0
var_dump($this->pagination); // Undefined property: Welcome::$pagination
exit;
}
}
发生了什么事?
----------------添加--------------
codeigniter的控制器代码......
class A {
protected static $instance;
public function __construct()
{
self::$instance = &$this;
}
public static function &get_instance()
{
return self::$instance;
}
}
class B extends A {
}
$b = new B();
$refA = &A::get_instance();
$refA->a = 'aaa';
echo $b === $refA; // echo 0 in windows(php 5.2.17), 1 in Linux (php 5.2.17)
是这个错误吗?