标签:rto foreach logs php new blog public 执行 val
<?php class talker { private $data = ‘Hi‘; public function & get(){ //返回值指向一个内容,这里是指向$data的内容, //测试:如果函数名前面不加&,下面执行的代码最终输出:HiHiHiHi return $this->data; } public function out() { echo $this->data; } } $aa = new talker(); $aa->out(); $b = & $aa->get(); //这里实际上指向$data的内容,改变$d的值则改变$data的内容 $b = ‘How‘; $aa->out(); $b = ‘Are‘; $aa -> out(); $b = ‘You‘; $aa -> out(); $b = ‘Hi‘; echo ‘<br />‘; //将$b改装为数组,foreach循环输出 $arr = array(‘How‘,‘Are‘,‘You‘); $aa->out(); $value = & $aa->get(); //将$value指向$data的内容 foreach($arr as $value) { $value = strtoupper($value); $aa->out(); } unset($value);//最后最好解绑 ?>
标签:rto foreach logs php new blog public 执行 val
原文地址:http://www.cnblogs.com/hubqin/p/6820312.html