Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> nie wywolywanie sie operacji
hhg
post 5.01.2007, 15:38:57
Post #1





Grupa: Zarejestrowani
Postów: 316
Pomógł: 0
Dołączył: 5.07.2006

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


pmam skrypt i nie wiem dlaczego operacja3 z klasy A sie nie wywoluje


  1. <?php
  2. class A
  3. {
  4. private function operacja1()
  5. {
  6. echo "operacja1 wywolana";
  7. }
  8.  
  9. protected function operacja2()
  10. {
  11. echo "operacja2 wywolana";
  12. }
  13.  
  14. public function operacja3()
  15. {
  16. echo "operacja3 wywolana";
  17. }
  18. }
  19.  
  20.  
  21. class B extends A
  22. {
  23. function __construct()
  24. {
  25. $this->operacja1();
  26. $this->operacja2();
  27. $this->operacja3();
  28. }
  29. }
  30.  
  31.  
  32. $b = new B();
  33. $b -> operacja3();
  34. ?>


czekam na Wasze odp

Ten post edytował hhg 5.01.2007, 15:40:46
Go to the top of the page
+Quote Post
Cysiaczek
post 5.01.2007, 15:42:15
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Moim zdaniem (interpreter się ze mną zgadza) ten skrypt zgłasza błąd.
Kod
Fatal error: Call to private method A::operacja1() from context 'B' in


Włącz sobie raportowanie błędów : )

Pozdrawiam.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
marast78
post 5.01.2007, 15:44:06
Post #3





Grupa: Zarejestrowani
Postów: 176
Pomógł: 0
Dołączył: 30.11.2004

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


a może wcześniej w konstruktorze wywoływana się metoda prywatna co jest błędem snitch.gif hermetyczność nie pozwala dziedziczyć prywatnych atrybutów i metod

Ten post edytował marast78 5.01.2007, 15:45:31


--------------------
Go to the top of the page
+Quote Post
hhg
post 5.01.2007, 15:52:46
Post #4





Grupa: Zarejestrowani
Postów: 316
Pomógł: 0
Dołączył: 5.07.2006

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


Cytat(Cysiaczek @ 5.01.2007, 15:42:15 ) *
Moim zdaniem (interpreter się ze mną zgadza) ten skrypt zgłasza błąd.
Kod
Fatal error: Call to private method A::operacja1() from context 'B' in


Włącz sobie raportowanie błędów : )

Pozdrawiam.

taki blad wlasnie powinien byc, bo to byl test
dzieki, gdzie sie wlacza raportowanie bledow? (Linux)

Ten post edytował hhg 5.01.2007, 15:52:59
Go to the top of the page
+Quote Post
Cysiaczek
post 5.01.2007, 15:54:01
Post #5





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




W pliku php.ini (każdy system)


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
marast78
post 5.01.2007, 15:55:58
Post #6





Grupa: Zarejestrowani
Postów: 176
Pomógł: 0
Dołączył: 30.11.2004

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


albo error_reporting(E_ALL);


--------------------
Go to the top of the page
+Quote Post
hhg
post 5.01.2007, 16:01:27
Post #7





Grupa: Zarejestrowani
Postów: 316
Pomógł: 0
Dołączył: 5.07.2006

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


dlaczego wypisuje mi sie 2razy ten tekst "operacja3 wywolana" zamiast raz...
  1. <?php
  2. class A
  3. {
  4. private function operacja1()
  5. {
  6. echo "operacja1 wywolana";
  7. }
  8.  
  9. protected function operacja2()
  10. {
  11. echo "operacja2 wywolana";
  12. }
  13.  
  14. public function operacja3()
  15. {
  16. echo "operacja3 wywolana";
  17. }
  18. }
  19.  
  20.  
  21. class B extends A
  22. {
  23. function __construct()
  24. {
  25. $this->operacja3();
  26. }
  27. }
  28.  
  29.  
  30. $b = new B();
  31. $b -> operacja3();
  32. ?>
Go to the top of the page
+Quote Post
Cysiaczek
post 5.01.2007, 16:04:37
Post #8





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




No przecież jawnie robisz to 2x :|||
Raz w konstruktorze, a raz wywołujesz osobno.
  1. <?php
  2. $b = new B();
  3. $b -> operacja3();
  4. ?>


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
hhg
post 5.01.2007, 16:42:55
Post #9





Grupa: Zarejestrowani
Postów: 316
Pomógł: 0
Dołączył: 5.07.2006

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


racja zapomnialem o konstruktorze
spokojnie dopiero zacząłem klasy... smile.gif

Cytat(Cysiaczek @ 5.01.2007, 15:54:01 ) *
W pliku php.ini (każdy system)
chodzi o linie ktora mam ustawiona na

Cytat
- display_errors = On

?

Ten post edytował hhg 5.01.2007, 16:12:04
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 12.08.2025 - 04:49