Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]dostep do funkcji z klasy
trucksweb
post
Post #1





Grupa: Zarejestrowani
Postów: 1 199
Pomógł: 31
Dołączył: 22.03.2004
Skąd: Warszawa

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


mam maly problem z klasa raportujaca o bledach w skrypcie.
Jesli rezygnuje z umeiszczenia tej funkcji w klasie wszystko dziala znakomicie, gdy funkcja jest w klasie ERRORS pojawia sie blad:
  1. <?php
  2. Warning: set_error_handler() expects the argument (my_error_handler) to be a valid callback in ...nazwa pliku
  3. ?>


oto dzialajaca funkcja:
  1. <?php
  2. function my_error_handler($e_number, $e_message, $e_file, $e_line, $e_vars){
  3.    global $live;
  4.    
  5.    $message = "Błąd skryptu: '$e_file'<br />wiersz: '$e_line'<br />rodzaj błędu: $e_message";
  6.    $message .= print_r($e_vars,1);
  7.    
  8.    //echo $message;
  9.  
  10.  }
  11. ?>


i jej wywolanie:
  1. <?php
  2. my_error_handler();  
  3. set_error_handler('my_error_handler');
  4. ?>


a to gdy tworze za pomoca klasy:
  1. <?php
  2. class ERRORS {
  3.  
  4.  public function my_error_handler($e_number, $e_message, $e_file, $e_line, $e_vars){
  5.    global $live;
  6.    
  7.    $message = "Błąd skryptu: '$e_file'<br />wiersz: '$e_line'<br />rodzaj błędu: $e_message";
  8.    $message .= print_r($e_vars,1);
  9.    
  10.    //echo $message;
  11.  
  12.  }  
  13.  
  14. }
  15. ?>


i wywolanie klasy:
  1. <?php
  2. $errors = new ERRORS;
  3. $errors->my_error_handler();  
  4. set_error_handler('my_error_handler');
  5. ?>


jakos nie umiem sobie z tym poradzic :/
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
czachor
post
Post #2





Grupa: Zarejestrowani
Postów: 897
Pomógł: 40
Dołączył: 16.12.2003
Skąd: Warszawa

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


  1. <?php
  2. set_error_handler(array('errors', 'my_error_handler'));
  3. ?>

Tylko metoda my_error_handler musi być chyba statyczna (nie pamiętam). Więcej: http://pl.php.net/manual/en/language.pseudo-types.php
Go to the top of the page
+Quote Post

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: 23.08.2025 - 22:59