Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] try {} catch {}
Eagle
post
Post #1





Grupa: Zarejestrowani
Postów: 170
Pomógł: 14
Dołączył: 16.03.2007

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


Witam

Mam sobie prostą funkcję załączania plików
  1. <?php
  2. public static function loadFile($fileName,$once = true)
  3.        {            
  4.            if(self::_seciurityCheck($fileName))
  5.            {
  6.                try
  7.                {
  8.                    if($once)
  9.                    {
  10.                        require_once ($fileName);
  11.                    }
  12.                    else
  13.                    {
  14.                        include ($fileName);
  15.                    }
  16.                }
  17.                catch(Exception $e)
  18.                {
  19.                    return false;    
  20.                }
  21.                // Plik zalaczony pomyslnie
  22.                  
  23.                return true;
  24.            }
  25.            return false;
  26.        }
  27. ?>


Jednak jeżeli jakiś plik nie istnieje to wyświetla normalne błąd jakby nie było try{}, catch{}.
Widzi ktoś co źle zrobiłem ?

Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
ziqzaq
post
Post #2





Grupa: Zarejestrowani
Postów: 428
Pomógł: 128
Dołączył: 17.06.2007

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


Bo to nie jest wyjątek (ang. exception) tylko błąd (error)?
Może spróbuj tych linków: exceptions, errorexception.
Możesz jeszcze spróbować ustawić error_handler.

Edit:
Z manuala:
Cytat
Informacja: Internal PHP functions mainly use Error reporting, only modern Object oriented extensions use exceptions. However, errors can be simply translated to exceptions with ErrorException.


Ten post edytował ziqzaq 14.01.2009, 21:59:41
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 Aktualny czas: 22.08.2025 - 03:51