Created
February 10, 2015 10:42
-
-
Save rightgo09/eebe2dfa6d3bac1308d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Hoge { | |
public $foo; | |
public function __construct(&$foo) { | |
$this->foo =& $foo; | |
} | |
public function &get_foo() { | |
return $this->foo['bar']; | |
} | |
public function aaa() { | |
$bar_foo =& $this->get_foo(); | |
$bar_foo['num'] = 10000; | |
} | |
} | |
$foo = array('bar' => array('num' => 23)); | |
$hoge = new Hoge($foo); | |
print_r($foo); | |
$hoge->aaa(); | |
print_r($foo); | |
//Array | |
//( | |
// [bar] => Array | |
// ( | |
// [num] => 23 | |
// ) | |
// | |
//) | |
//Array | |
//( | |
// [bar] => Array | |
// ( | |
// [num] => 10000 | |
// ) | |
//) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment