Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ContentHolder
- {
- private $content;
- public function __construct()
- {
- $this->content = "";
- }
- public function getContent()
- {
- return $this->content;
- }
- }
- $c = new ContentHolder();
- $foo = array();
- $foo['c'] = $c->getContent();
- public function &getContent()
- {
- return $this->content;
- }
- $foo['c'] = &$c->getContent();
- public function __construct() {
- $this->content = "test";
- }
- $c = new ContentHolder();
- $foo = array();
- $foo['c'] = $c->getContent();
- print $foo['c']; // prints "test"
- print $c->getContent(); // prints "test"
- var_dump($foo);
- array(1) {
- ["c"]=>
- string(0) ""
- }
- echo "foo[c] = '" . $foo['c'] . "'n";
- foo[c] = ''
Add Comment
Please, Sign In to add comment