Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] tworzenie iteracji w obiekcie
cesyn
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 27.07.2010

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


Witam wszystkich,

Mam takie pytanie chcę uzyskać taki efekt;
  1. Dirs Object
  2. (
  3. [wynik] => Array
  4. (
  5. [0] => Array
  6. (
  7. [name] => ..
  8. [path] => /
  9.  
  10. )
  11.  
  12. [1] => Array
  13. (
  14. [name] => plik2.doc
  15. [path] => /var/hhh
  16.  
  17. )
  18.  
  19. [2] => Array
  20. (
  21. [name] => plik.doc
  22. [path] => /home/
  23.  
  24. )
  25.  
  26. )
  27.  
  28.  
  29. )


Czy wykonanie tego w taki sposób jest zgodne z oop?
  1.  
  2. class Dirs {
  3.  
  4. function Dirs()
  5. {
  6.  
  7. }
  8. function setName($name)
  9. {
  10. $this->nazwa=$name;
  11. }
  12. function setPath($path)
  13. {
  14. $this->sciezka=$path;
  15. }
  16. function wyk()
  17. {
  18. $this->wynik[] = array('name'=>$this->nazwa,'path'=>$this->sciezka);
  19. }
  20. }
  21. class Jakas{
  22.  
  23. function Jakas()
  24. {
  25. require_once('dirs.class.php');
  26. $dirs = new Dirs();
  27. $this->dirs = $dirs;
  28.  
  29. $this->dirs->setName("..");
  30. $this->dirs->setPath('/');
  31. $this->dir->wyk();
  32.  
  33. $this->dirs->setName("plik2.doc");
  34. $this->dirs->setPath('/var/hhh');
  35. $this->dir->wyk();
  36.  
  37. $this->dirs->setName("plik.doc");
  38. $this->dirs->setPath('/home/');
  39. $this->dir->wyk();
  40. }
  41. }


Z góry dziękuję za wszystkie sugestie party.gif

Pozdrawiam

Ten post edytował cesyn 27.07.2010, 00:33:09
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: 21.08.2025 - 14:53