同じクラスの別の関数の変数を表示するにはどうすればよいですか?
ここに私が持っている問題があります:
class slike {
public function __construct($dire) {
$this->dire=$dire;
}
function skupljanjeslika() {
$slike = array();
$handler = opendir($this->dire);
while ($file = readdir($handler)) {
if ($file != "." && $file != "..") {
$slike[] = $file;
}
}
closedir($handler);
return $slike; // **Array i want to use!**
}
function prikazradnomslike() {
$slike; // Here is the array from first function, but I can't see it here
$rezultat = count($slike)-1;
$koliko=rand(0, $rezultat);
$slika=$slike[$koliko];
return $slika;
}
}