Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> "jak wywołać funkcje klasy a poprzez fukncje klasy b"
survi91
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 2.03.2012

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


Witam,

  1. <?php
  2. //zmienne przekazane:
  3. //$name, $surname, $email
  4. class parents
  5. {
  6. function callFunction($name, $surname, $email)
  7. {
  8. $this->setData($name, $surname, $email);
  9. $this->xx();
  10. $this->setidparent();
  11. //jeszcze kilka innych, ktore omijam
  12. }
  13.  
  14. protected function setData($name, $surname, $email)
  15. {
  16. $this->name=$name;
  17. $this->surname=$surname;
  18. $this->email=$email;
  19. }
  20.  
  21. protected function xx ()
  22. {
  23. $x= mysql_query( .......);
  24. $this->id=$id;
  25. }
  26. protected function setidparent()
  27. {
  28. $IDparent=$this->id;
  29. if($IDparent == null)
  30. print "NULL";
  31. return $IDparent;
  32. }
  33. }
  34.  
  35. class y
  36. {
  37. function yy()
  38. {
  39. $x=$parent->$this->setidparent(); w TEJ FUNKCJI CHCIALBYM ZEBY MI SIE WYSWIETLILO $id z funkcji xx z klasy parents
  40. echo$x;
  41. }
  42. }
  43.  
  44. $parent = new parents;
  45. $parent -> callFunction($name, $surname, $email);
  46.  
  47. $student = new y;
  48. $student -> yy();
  49. ?>


Wartosc $id z funckji xx klasy parents powinna byc wyswietlona poprzez wywolanie funkcji yy z klasy y
Dostaje rózne errory, pewnie to jest jakiś syntax error o którym nie wiem, proszę o pomoc.

Dzięki, doszedlem już do tego sam (IMG:style_emoticons/default/wink.gif)
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 24.08.2025 - 11:41