<?php
/**
* Copyright (c) 2009
* All rights reserved.
*
* 名 称:
* 摘 要:
* 版 本:1.0
* @author zhoudan
* @since 10.03.24 17:06:53
*/
class App{
public $a = array(1,2,3,4);
function &getA()
{
return $this->a;
}
function p()
{
print_r($this->a);
}
}
class Test{
private $app;
function __get($name)
{
if($name === "a")
{
$this->a = &$this->app->getA();
return $this->a;
}
}
public function __construct(App $app)
{
$this->app = $app;
}
public function p()
{
$a = &$this->a;
$a[0] = 100;
//$this->a[0] = 100;
$this->test();
print_r($this->a);
}
public function test()
{
$test = &$this->a;
$test[1] = 100;
}
}
$app = new App();
$test = new Test($app);
$test->p();
$app->p();
?>
php __get 函数一个隐藏问题
最新推荐文章于 2021-04-11 04:11:04 发布