【发布时间】:2010-12-24 17:47:32
【问题描述】:
我在访问类中的变量时遇到问题,这是代码
class Text {
private $text = '';
private $words = '';
// function to initialise $words
private function filterText($value,$type) {
$words = $this->words;
echo count($words); // works returns a integer
if($type == 'length') {
echo count($words); // not works returns 0
}
$this->words = $array;
}
// even this fails
public function filterMinCount($count) {
$words = $this->words;
echo count($words);
if(true){
echo 'bingo'.count($words);
}
}
}
谁能告诉我原因
【问题讨论】:
-
如果你有另一个变量可以使用,你为什么要这样做?