note 103794 deleted from language.references.pass by googleguy
| From: | googleguy@php.net | Date: | Sun, 23 Feb 2014 17:20:43 +0000 |
| Subject: | note 103794 deleted from language.references.pass by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198606@lists.php.net to get a copy of this message | ||
Note Submitter: 4d88 dot results at gmail dot com
----
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"