Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> czytanie watoci zmiennych w funkcji
MitS
post
Post #1





Grupa: Zarejestrowani
Postów: 262
Pomógł: 5
Dołączył: 8.02.2005
Skąd: Olsztyn / Zatorze

Ostrzeżenie: (0%)
-----


witam mam maly problem... otoz pare dni temu zabralem sie za programowanie obiektowe no i od razu natrafilem na problem z którym se nie moge poradzić ... otoz mam klase:
  1. <?php
  2. class Gallery {
  3. private $arrow_left, $arrow_right, $symbol_left, $symbol_right, $link;
  4. private $dir;
  5.  
  6. public function _construct($dir, $arrow_left, $arrow_right, $symbol_left, $symbol_right, $link) {
  7. $this->_dir = $dir;
  8. $this->_arrow_left = $arrow_left;
  9. $this->_arrow_right = $arrow_right;
  10. $this->_symbol_left = $symbol_left;
  11. $this->_symbol_right = $symbol_right;
  12. $this->_link = $link;
  13. }
  14.  
  15. private function get_files($folder, $filtr){
  16. $katalog=opendir($folder);
  17. $file=array(); 
  18. while ($next_file = readdir($katalog)){
  19. if (is_file($folder.'/'.$next_file) && ereg($filtr, $next_file)){
  20.  $file[]=$next_file;
  21. }
  22. }
  23. closedir($katalog);
  24. sort($file);
  25. return $file;
  26. }
  27.  
  28. public function show_gallery(){
  29. $pliki = $this->get_files($this->_dir, ".jpg$|.gif$");
  30. if($_GET['todo'] == '') $nr = 0;
  31. else $nr = $_GET['todo'];
  32.  
  33. if (isset($nr)) {
  34. if ($nr==0)
  35.  echo '
  36.  <img src="'.$this->_arrow_left.'" alt="'.$this->_symbol_left.'" />';
  37. else  
  38. echo '
  39. <a href="'.$this->_link.'?mod=gallery&todo='.($nr-1).'" onfocus="blur();">
  40. <img src="'.$this->_arrow_left.'" alt="'.$this->_symbol_left.'" />
  41. </a>';
  42. if ($nr==(count($pliki)-1))
  43.  echo '
  44.  <img src="'.$this->_arrow_right.'" alt="'.$this->_symbol_right.'" />';
  45. else  
  46. echo '
  47. <a href="'.$this->_link.'?mod=gallery&todo='.($nr+1).'" onfocus="blur();">
  48. <img src="'.$this->_arrow_right.'" alt="'.$this->_symbol_right.'" />
  49. </a>';  
  50.  
  51. echo '<br /><br />
  52. <div>
  53. <img src="'.$this->_dir.'/'.$pliki[$nr].'" alt="'.($nr+1).'" />
  54. </div>';
  55.  }
  56. }
  57. }
  58. ?>


oraz plik php:

  1. <?php
  2.  
  3. $dir = './gallery';
  4. $arrow_left = '';
  5. $arrow_right = '';
  6. $symbol_left = '<<';
  7. $symbol_right = '>>';
  8. $link = 'index.php';  
  9.  
  10. $gallery = new Gallery($dir, $arrow_left, $arrow_right, $symbol_left, $symbol_right, $link);
  11.  
  12. $slide = $gallery->show_gallery();
  13.  
  14. echo $slide;
  15. ?>


no i blądów jest co niemiara...
Moje pytanie ... jak z konstruktora przenieść zmienne do funkcji show_gallery()
by bylo ok questionmark.gif?

bo jak robie tak jak powyzej to wywala mi takie blędy:

Kod
Notice: Undefined property: Gallery::$_dir in /var/www/html/piaskownica/__classes/class.Gallery.php on line 40
Warning: readdir(): supplied argument is not a valid Directory resource in /var/www/html/piaskownica/__classes/class.Gallery.php on line 23
Warning: closedir(): supplied argument is not a valid Directory resource in /var/www/html/piaskownica/__classes/class.Gallery.php on line 31
Notice: Undefined property: Gallery::$_link in /var/www/html/piaskownica/__classes/class.Gallery.php on line 55
Notice: Undefined property: Gallery::$_arrow_left in /var/www/html/piaskownica/__classes/class.Gallery.php on line 56
Notice: Undefined property: Gallery::$_symbol_left in /var/www/html/piaskownica/__classes/class.Gallery.php on line 56
Notice: Undefined property: Gallery::$_link in /var/www/html/piaskownica/__classes/class.Gallery.php on line 64
Notice: Undefined property: Gallery::$_arrow_right in /var/www/html/piaskownica/__classes/class.Gallery.php on line 65
Notice: Undefined property: Gallery::$_symbol_right in /var/www/html/piaskownica/__classes/class.Gallery.php on line 65
Notice: Undefined property: Gallery::$_dir in /var/www/html/piaskownica/__classes/class.Gallery.php on line 70
Notice: Undefined index: 7 in /var/www/html/piaskownica/__classes/class.Gallery.php on line 70
" title="Zobacz w manualu PHP" target="_manual">
Notice: Undefined property: Gallery::$_dir in /var/www/html/piaskownica/__classes/class.Gallery.php on line 40
Warning: readdir(): supplied argument is not a valid Directory resource in /var/www/html/piaskownica/__classes/class.Gallery.php on line 23
Warning: closedir(): supplied argument is not a valid Directory resource in /var/www/html/piaskownica/__classes/class.Gallery.php on line 31
Notice: Undefined property: Gallery::$_link in /var/www/html/piaskownica/__classes/class.Gallery.php on line 55
Notice: Undefined property: Gallery::$_arrow_left in /var/www/html/piaskownica/__classes/class.Gallery.php on line 56
Notice: Undefined property: Gallery::$_symbol_left in /var/www/html/piaskownica/__classes/class.Gallery.php on line 56
Notice: Undefined property: Gallery::$_link in /var/www/html/piaskownica/__classes/class.Gallery.php on line 64
Notice: Undefined property: Gallery::$_arrow_right in /var/www/html/piaskownica/__classes/class.Gallery.php on line 65
Notice: Undefined property: Gallery::$_symbol_right in /var/www/html/piaskownica/__classes/class.Gallery.php on line 65
Notice: Undefined property: Gallery::$_dir in /var/www/html/piaskownica/__classes/class.Gallery.php on line 70
Notice: Undefined index: 7 in /var/www/html/piaskownica/__classes/class.Gallery.php on line 70


Pozdrawiam

Ten post edytował MitS 23.03.2007, 14:05:31
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 12:35