Skip to content

Instantly share code, notes, and snippets.

@rightgo09
Created February 10, 2015 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightgo09/eebe2dfa6d3bac1308d8 to your computer and use it in GitHub Desktop.
Save rightgo09/eebe2dfa6d3bac1308d8 to your computer and use it in GitHub Desktop.
<?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