note 103794 modified in language.references.pass by thiago
| From: | thiago@php.net | Date: | Wed, 04 May 2011 03:44:40 +0000 |
| Subject: | note 103794 modified in language.references.pass by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179398@lists.php.net to get a copy of this message | ||
This is the way how we use pointer to access variable inside the class.
<?php
class talker{
private $data = 'Hi';
public function & get(){
return $this->data;
}
public function out(){
echo $this->data;
}
}
$aa = new talker();
$d = &$aa->get();
$aa->out();
$d = 'How';
$aa->out();
$d = 'Are';
$aa->out();
$d = 'You';
$aa->out();
?>
the output is "HiHowAreYou"
--was--
This is the way how we use pointer to access variable inside the class.
class talker{
private $data = 'Hi';
public function & get(){
return $this->data;
}
public function out(){
echo $this->data;
}
}
$aa = new talker();
$d = &$aa->get();
$aa->out();
$d = 'How';
$aa->out();
$d = 'Are';
$aa->out();
$d = 'You';
$aa->out();
the output is "HiHowAreYou"
http://php.net/manual/en/language.references.pass.php