Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Class Exception - błąd, Class Exception
bigos1995-95
post
Post #1





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 18.05.2012

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


  1. class Exception {
  2. function __construct(string $message=NULL, int $code=0) {
  3. if (func_num_args()) {
  4. $this->message = $message;
  5. }
  6. $this->code = $code;
  7. $this->file = __FILE__; // dla klauzuli throw
  8. $this->line = __LINE__; // dla klauzuli throw
  9. $this->trace = debug_backtrace();
  10. $this->string = StringFormat($this);
  11. }
  12.  
  13. protected $message = "Unknown exception"; // komunikat wyjątku
  14. protected $code = 0; // kod wyjątku definiowany przez użytkownika
  15. protected $file; // nazwa pliku źródłowego z wyjątkiem
  16. protected $line; // numer wiersza z wyjątkiem
  17.  
  18. private $trace; // stos wywołań w momencie wyst. wyjątku
  19. private $string; // wykorzystywana wewnętrznie!!
  20.  
  21. final function getMessage(){
  22. return $this->message;
  23. }
  24.  
  25. final function getCode() {
  26. return $this->code;
  27. }
  28. final function getFile() {
  29. return $this->file;
  30. }
  31. final function getTrace() {
  32. return $this->trace;
  33. }
  34. final function getTraceAsString() {
  35. return self::TraceFormat($this);
  36. }
  37. function _toString() {
  38. return $this->string;
  39. }
  40. static private function StringFormat(Exception $exception) {
  41. // ... funkcja niedostepna w skryptach PHP
  42. // zwraca wszystkie informacje w postaci ciagu
  43. }
  44. static private function TraceFormat(Exception $exception) {
  45. // ... funkcja niedostepna w skryptach PHP
  46. // zwraca zapis stosu wywolan w postaci ciagu
  47. }
  48. }




Po wywołaniu tego kodu wyrzuca mi błąd : Fatal error: Default value for parameters with a class type hint can only be NULL in C:\wamp\www\bigos\tbl\tbl.php on line 2. Mogłby mi ktoś powiedzieć co tu jest źle ??Pomijając to ze w ogole tego kodu nie rozumiem, ponieważ jest on z nowego tematu który właśnie zacząłem.
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: 15.09.2025 - 16:29